<tricksy>
Interesting. But that would require any implementation of `name` to know what the "last" implementation was so that it could use it as its fallback.
<tricksy>
And if I did dozens of that it would probably start to hurt performance.
<tricksy>
In my situation I don't really need the open types. Just thought it would be neater to not have to define everything in one place. So I'll probably use an ordinary variant.
<tricksy>
Thanks for the help though!
<ggole>
Yeah, everything in one place isn't really all that bad
<tricksy>
I currently have a 400 line "types.ml" due to the fact that my types mutually refer to each other, so I'm used to it...
<ggole>
Oh yeah, that's always fun
<ggole>
I regularly bitch about how file-level modules can't mutually refer to each other
TheLemonMan has quit [Quit: Lost terminal]
manizzle has joined #ocaml
lolisa has joined #ocaml
ollehar has quit [Ping timeout: 260 seconds]
antoro is now known as antoro_
TRUMP-PENCE has quit [Remote host closed the connection]
<rgrinberg>
I think we can ninja rename it later anyway, i don't expect people to use this function
<rgrinberg>
Although i'm wondering if it's worth marking it as "experimental" or something in the doc
silver has quit [Quit: rakede]
shon has quit [Remote host closed the connection]
<mrvn>
always
LiamGoodacre has quit [Ping timeout: 250 seconds]
antoro is now known as antoro_
ggole_ has quit []
shon has joined #ocaml
shon has quit [Ping timeout: 240 seconds]
shon has joined #ocaml
octachron has quit [Quit: Leaving]
<Heasummn>
If I have a bunch of data types that all take 2 arguments, and I'd like to do the exact same thing with those two arguments, is there any syntactic construct that makes it easier to match against them?
<Heasummn>
For example:
shon has quit [Remote host closed the connection]
<Heasummn>
Add(e1, e2), Sub(e1, e2), Div(e1, e2), Mult(e1, e2) Are all datatypes. In which e1 and e2 are all of the same type.
AlexRussia has joined #ocaml
<Heasummn>
A match like (Add | Sub | Mult | Div) (e1, e2), or something like that, if it exists
dexterph has quit [Ping timeout: 240 seconds]
<Heasummn>
The simplest method I could conjure is: match expr with | Add (e1, e2) | Sub(e1, e2) | Mult (e1, e2) | Div (e1, e2) -> blah
<Heasummn>
I'm not even sure if tha tworks though
wtetzner has quit [Remote host closed the connection]
wtetzner has joined #ocaml
shon has joined #ocaml
AlexRussia has quit [Ping timeout: 258 seconds]
octachron has joined #ocaml
<octachron>
Heasummn, matching over an or pattern Add(e1,e2) | ... | Div(e1,e2) would work
<octachron>
another option might be to split the type in a BinOp of bin_op * expr * expr and type bin_op = Add | ...| Div
<octachron>
then, you could match over BinOp( _, e1, e2)
<Heasummn>
I plan to do that later. It'll make overloading operators easier too
kev has quit [Ping timeout: 264 seconds]
<Heasummn>
I'll do it in the next commit, I have to fix some errors in this one
tane has quit [Quit: Leaving]
<Heasummn>
I've got a bug in my code and I think it has to do with equality testing
<Heasummn>
If I have a variant tp = Tint | Tfloat
<Heasummn>
I can do if (x = Tint) and assume that is true if x is a variant of type Tint?
<octachron>
yes?
<Heasummn>
alright
<Heasummn>
Because = and == are two different levels of comparison
<Heasummn>
I was unsure
<Heasummn>
This is getting really fucking annoying then. Everything I check tells me that these two items are the same, but my if expression always results to the else case
<pierpa>
paste a snippet
<Heasummn>
one sec
<Heasummn>
That's weird
<Heasummn>
I was using a function to abstract away the messy if checking. If I don't use that function, then it's all fine
<pierpa>
have you any nested ifs? or nested anything?
<Heasummn>
yeah
<Heasummn>
nested ifs
<Heasummn>
in that faulty function
<pierpa>
hmmmm
<Heasummn>
I wasn't focusing on that function, let me debug it
<pierpa>
try the following: program as if the syntax of if was: if e0 then begin e1 end else begin e2 end
<pierpa>
with begin/end mandatory
<Heasummn>
Changing some parenthesis around fixed it
<Heasummn>
I was stuck debugging the wrong thing for about 30 minutes
<pierpa>
parenthesis work to, but I like begin/end more
kakadu has quit [Remote host closed the connection]