<Demitar>
That ought to be more fruitful than looking at the bnf grammar, thanks. :)
<vincenz>
method fold : 'a. ('a -> int -> 'a) -> 'a -> 'a =
<vincenz>
but you have to make a function inside
<vincenz>
method fold : 'a. ('a -> int -> 'a) -> 'a -> 'a = fun ...
<vincenz>
you have to assign a func to it
<vincenz>
work now?
<Demitar>
Yes.
<Demitar>
But wrapping a function inside feels a tad awkward.
<vincenz>
yeah
<vincenz>
don't know why
<vincenz>
anyways
<vincenz>
gotta go
zzorn has joined #ocaml
smkl has quit [Read error: 238 (Connection timed out)]
Submarine has quit ["Leaving"]
<dan2>
Demitar: how do I make a larger if statement
<dan2>
do I use begin end?
<mflux_>
you may use begin/end or parenthesis
<dan2>
mflux_: thanks
<mflux_>
I however often use construct let _ = () in
<dan2>
mflux_: ugh
<mflux_>
but sometimes when you need to bind something anyway, that can be avoided
<Demitar>
mflux_, dangerous though. Since it doesn't catch partial applications. :)
<mflux_>
demitar, hmm?
<Demitar>
let _ = String.sub in doesn
<Demitar>
't warn.
<mflux_>
but that's not what I wrote
<Demitar>
What you wrote was a no-op so I took the liberty of extending the thought. ;-)
<mflux_>
if true then let _ = () in insert_code_here; more_code; else bar
<Demitar>
That works?
<mflux_>
yes
<Demitar>
Strange scoping.
<mflux_>
I don't find it very strange
<mflux_>
but it doesn't mean it couldn't be ;)
<Demitar>
Well usually the if statement ends with the first semicolon. It becomes odd in a case like this: if false then let cow = "cow" in print_endline (cow ^ cow); (* here I expect to back at the pre-if level *) print_endline "regardless of wether the previous test worked ...";
<mflux_>
let foo = let a = 42 in let b = 66 in a + b; Printf.printf "%d\n" (a - b);
<mflux_>
whops, add () after 'foo'
<mflux_>
do you expect the function not to include the printf?
<mflux_>
(note that the function makes no sense ;))
<Demitar>
mflux_, thing is that I would also naively expect if true then print_endline "foo"; print_endline "bar" else print_endline "quux"; to work.
<mflux_>
well the problem comes from that else is optional
<mflux_>
what would you expect if true then if true then a else b to return?
<mflux_>
hmph, make that second true to false
<mflux_>
or first true to false
<Demitar>
The if statement has a tad of a relearning curve coming from other languages, and then the let _ () in comes and makes what one originally thought would work be true again, it's unexpected to say the least.
<mflux_>
in any case, you can use an editor that automatically indents the code ;)
gim has joined #ocaml
<mflux_>
the thing is that one is 'expected' to write mostly functional code
<mflux_>
so there rarely are consecutive statements
<mflux_>
and ifs always have an else-branch
<Demitar>
Yes, it's not a huge problem but the fact that one all of the sudden has to *limit* the scope of if rather than extend it is definitely not along the lines of least suprise.
<mflux_>
you can still write if foo then begin asdfasdf; babar; end if you want
<mflux_>
and I would imagine atleast for old pascal programmers that seems quite natural
<mflux_>
well, for c/c++/java-writers too infact
<mflux_>
but 'let a = 42 in' is some sort of a scoping construct not similar to ones in those languages
<mflux_>
and can be 'abused' with that let _ = () -thingy
<Demitar>
Yes, in the end, it's the scoping of let ... in is what isn't quite expected.
smkl has joined #ocaml
Submarine has joined #ocaml
TFK has joined #ocaml
smkl has quit [Read error: 238 (Connection timed out)]
mrvn_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
mrvn_ is now known as mrvn
smkl has joined #ocaml
pango has quit [Read error: 110 (Connection timed out)]
pango has joined #ocaml
_shawn has joined #ocaml
shawn_ has quit [Read error: 110 (Connection timed out)]
smimou has quit ["?"]
vezenchio has quit ["haibane · renmei"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
smkl has quit [Read error: 238 (Connection timed out)]
pharx has quit []
stef_ has joined #ocaml
mrsolo_ has quit [Read error: 54 (Connection reset by peer)]
mrsolo_ has joined #ocaml
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
smkl has joined #ocaml
hangman4 has quit [Read error: 110 (Connection timed out)]
smkl has quit [Read error: 238 (Connection timed out)]
Submarine has quit ["Leaving"]
drz has quit ["using sirc version 2.211+KSIRC/1.3.11"]