<everyonemines>
Yeah, the final one should be a ;;
<thelema>
;; is optional.
<everyonemines>
not always
<everyonemines>
but usually
<thelema>
if you use `let _ = `, then ;; is optional
<Drakken>
It sounds like he wants to make the operations sequential. [in] and [;] both force the expressions to be evaluated in the order they're written in.
<thelema>
everyonemines: why do you want to do this transform? except for toplevel # directives, everything you type at the toplevel is valid as-is in an ocaml program
<thelema>
Drakken: ;; does too.
<everyonemines>
Sometimes I have some non-function ocaml code and it needs to be converted to a function.
<Drakken>
Maybe he wants the file to be converted into a function instead of a module?
<everyonemines>
Basically that, yes.
<everyonemines>
I guess this is the reason why people use "let _ ="
<Drakken>
I've asked why ppl do that , but thelema won't tell me.
<Drakken>
:)
<everyonemines>
Well, it lets you convert something to a named function later.
<everyonemines>
But saves you the trouble of writing "let exec() = ...;; exec()" all the time
<everyonemines>
but on the other hand it would be more flexible to convert an arbitrary selection to a function after writing a bunch of code.
<everyonemines>
and I don't like "let _ ="
<Drakken>
everyonemines there's no main function in ocaml that automatically get evaluated. Either you write the code as top-level expressions or you write [main();;] at the end of your file.
<Drakken>
Each file is turned into a module.
<everyonemines>
huh? I wouldn't have gotten much done with ocaml if I didn't know that.
<everyonemines>
kind of hard to get very far without finding that out
<Drakken>
but you seem to be asking it to do something else.
<everyonemines>
I want a utility that converts some ocaml code to function form.
<_habnabit>
you could just not write it not in 'function form
<_habnabit>
'
<Drakken>
you mean the whole file is a function instead of a module. So the function is really an action. It doesn't take any arguments.
<everyonemines>
I think the way to go is to use ;; after every let
<everyonemines>
and only ; after commands
<everyonemines>
and then replace ;; with in
<everyonemines>
then turn the final in to ;; again
<_habnabit>
seriously why are you writing ;; in files at all??? I only /ever/ write ;; in the toplevel
<everyonemines>
no I'm saying, if I did that for every let
<everyonemines>
I could search/replace to "in"
<Drakken>
everyonemines do you want to compile a file into a function or do you want to translate some source code into different source code?
<everyonemines>
and you need ;; if you want something like let x = 10;; print_endline "hello"
<everyonemines>
the latter
<_habnabit>
eh? `let x = 10 in print_endline "hello"`
<everyonemines>
no, that's different
<_habnabit>
hell, you don't even need the `in`
<_habnabit>
just put them on separate lines
<everyonemines>
haha try it
<everyonemines>
it won't work
<_habnabit>
oh, right, you're trying to apply a function
<_habnabit>
which is something I never do since I rarely have any entry points
<_habnabit>
`let () = print_endline "hello"` done
<everyonemines>
is that different from let _ ?
<_habnabit>
it enforces that the expression's type is unit
emmanuelux has quit [Ping timeout: 252 seconds]
<everyonemines>
anyway your solution doesn't help with my problem
<everyonemines>
what if you want to convert that code to a function automatically?
<_habnabit>
I still don't understand how there's a problem at all
<everyonemines>
you need to add an "in"
<everyonemines>
if you used ;; you could search/replace
<_habnabit>
why do you have to do this 'automatically'? why are you writing it /not/ in this way in the first place?
<everyonemines>
I already explained that above.
<_habnabit>
I didn't see any explanation
<everyonemines>
Well, my solution is to use ;; and that's good enough.
<everyonemines>
that's my conclusion
<_habnabit>
using ;; seems like it's completely silly in all cases
<everyonemines>
no worse than writing in
<everyonemines>
actually faster to type
dnolen has joined #ocaml
<_habnabit>
no, seriously, how do you have so many places that you want to call a function that's not within another function?
<_habnabit>
the only time this is relevant /at all/ is when you're writing an entry point into a program
<everyonemines>
that's one of those philosophical questions
<_habnabit>
no, it isn't. it's a design question.
<everyonemines>
You mean, why not pack everything into functions and have a single main() at the end?
brendan has joined #ocaml
<everyonemines>
Well, first off, super long functions make me uncomfortable.
<_habnabit>
eh? that's a hell of a false dichotomy. write lots of functions.
<everyonemines>
And breaking some things up into smaller functions is not possible.
<_habnabit>
and having a super long block of code that's not in /any/ function makes me much more uncomfortable
<everyonemines>
but you can pump some test setup into the interpreter
<everyonemines>
and copy paste it in
<everyonemines>
can't do that if it's in a function
<everyonemines>
Packing things into functions hardcodes certain clumpings of operations.
<_habnabit>
... sure you can. having to 'copy paste' things to run tests is insane anyway.
<everyonemines>
And sometimes you need to rearrange them as you're coding frequently.
<Drakken>
everyonemines that must be a very complex function.
<_habnabit>
okay ??? how does having things not in a function help with that
<_habnabit>
if you're not doing automated testing, you might as well not be doing any testing at all
<everyonemines>
Drakken: well, I do break stuff into functions, but it can be hard to get them under a couple thousand lines
<_habnabit>
/thousand/ ?
<everyonemines>
when there's a lot of shared state
<Drakken>
everyonemines you're doing it wrong.
<Drakken>
You need to split the code into smaller functions.
<Drakken>
I'm sure it's possible/easy.
<everyonemines>
you can't just magic away lots of shared state with functional pixie dust
<Drakken>
I bet you can :)
<everyonemines>
you would end up with 100 functions taking 30 parameters
<Drakken>
globals
<_habnabit>
no, not globals
<_habnabit>
never globals.
<Drakken>
I want to see that code
<everyonemines>
But yeah, I think I'll use ;; every let, remember to only use ; for commands, then do a search/replace on a selection when I'm happy with an arrangement.
<everyonemines>
not ideal but good enough
<_habnabit>
it really isn't, no
<_habnabit>
it's not even 'good enough;'
<Drakken>
I'm not even sure it's real
<_habnabit>
you do know that you can run tests automatically, yes?
<_habnabit>
without you having to 'pump setup' and copy paste things?
<everyonemines>
ummm
<everyonemines>
you can't just generate appropriate input data for part of a program automatically
<everyonemines>
you need to write code to generate it
<_habnabit>
okay and ??? I never said anything suggesting otherwise
<everyonemines>
And you only need to retest a section when changing it.
<_habnabit>
yes ???
<_habnabit>
what relevance does anything you just said have to what I said
<everyonemines>
So what part are you automating?
<everyonemines>
The problem is, it would be too difficult to write verification tests.
<_habnabit>
setting up the environment and then running the functions on your preconstructed data
<everyonemines>
I need to look at the output manually for most stuff where I might make mistakes.
<Drakken>
I wonder if he wants to copy code segments out of his megafunction and paste them individually into tests.
<everyonemines>
that's exactly what I do!
<_habnabit>
no, you verify the output automatically too
<everyonemines>
it is not possible
<everyonemines>
I use SAGE and my brain to see if it's working right
<everyonemines>
writing a smart enough program would be too hard
<everyonemines>
I guess you could write some sanity checks but generally problems are too subtle for that to help at all.
<everyonemines>
well, writing a program to verify, and writing it correctly, would be as hard as writing the actual code in the first place
<everyonemines>
so if I made a mistake with one I'd mess up the verification code
<Drakken>
everyonemines you're better off with 30 arguments in your functions. assuming that's really necessary.
<Drakken>
(*small* functions)
<everyonemines>
That's basically manual closure conversion. It makes code harder to read, but while I don't find it worthwhile by hand
<everyonemines>
if there was an automated conversion for that I might use it sometimes.
<everyonemines>
I'm not anti-testing, it's just only helpful when you have easily checked and important invariants to test against.
<everyonemines>
That's not always the case.
<everyonemines>
Also, the performance of code written that way can be worse, but I think with MLton it wouldn't matter.
<everyonemines>
Drakken: It's an AI thing.
<Drakken>
a thousand lines. that's pretty long.
<everyonemines>
well, I use ( on its own line
<everyonemines>
by the way, autoparens is the best thing ever
<everyonemines>
why yes, I would like a matching ) with that
<Drakken>
Well, I would sacrifice a lot of readability if it bought me decent automatic testing.
<Drakken>
If it was the *only* alternative.
<everyonemines>
I'm telling you, the testing code would be as hard to write as the code itself here. And just as bug-prone.
<Drakken>
How is it any easier to test code snippets?
<everyonemines>
What I DO do is use typedefs to help avoid bugs.
<everyonemines>
What's easier is looking at the output manually through viewing functions.
<everyonemines>
Compared to writing tests.
<Drakken>
what do you mean by "viewing functions"?
<everyonemines>
functions to transform the output to something I read
<Drakken>
Why do you need to reformat the code? Can't you just paste it into a little test function?
<everyonemines>
No, it's to reformat the output to make it easier to examine for correctness.
<Drakken>
You mean you're writing macros?
<Drakken>
outputting code?
<everyonemines>
huh?
<everyonemines>
code -> output data -> viewing function -> me
<Drakken>
What kind of data is this?
<everyonemines>
...arrays of numbers?
<everyonemines>
actually it's me -> parameters -> test gen code -> code -> output data -> viewing function -> me
<Drakken>
Which phase are we talking about?
dnolen has quit [Quit: dnolen]
<Drakken>
I don't see how numbers or viewing functions are relevent to your earlier questions.
<everyonemines>
They're not really, I was just answering what you asked.
<everyonemines>
and "just write an automated test" got me a little annoyed I guess
<Drakken>
what does the "test gen code" phase do?
<everyonemines>
It generates the data input for a program fragment.
<everyonemines>
The thing is, that's much more work for small fragment tests, because of all the intermediate data generated.
<everyonemines>
If there is some principle I'm missing that would make it easier for me, I'd be very interested....
<everyonemines>
but "just write automated tests, it's easy, I do it all the time" isn't helpful!
<Drakken>
What about just sprinkling print statements in the code?
<everyonemines>
Well, if everything before something works, then you can do that.
<everyonemines>
But you can't just develop from the input onward, you can't plan that far ahead.
<everyonemines>
I mean *I* can't.
<everyonemines>
Secondly, print statements are dumb. If you're running in the interpreter you can run functions on variables and poke around, but instead of print statements
<everyonemines>
it's much better to pipe to a file.
<everyonemines>
well, not pipe, just write
<Drakken>
whatever
<Drakken>
Wait a second. First you said you wanted to reformat code, then you said you want to reformat "output".
<Drakken>
which you just said is numbers.
<everyonemines>
No, I do reformat output. I wanted a way to reformat code.
<Drakken>
What would you do with the reformatted code?
<everyonemines>
. . . .
everyonemines has left #ocaml []
EmmanuelOga has quit [Ping timeout: 248 seconds]
nixfreak_ has quit [Ping timeout: 260 seconds]
arubin has quit [Quit: arubin]
<Drakken>
omg was he saying he wants to write pieces of toplevel test code and automatically assemble them into the megafunction?
<Drakken>
I hope he codes better than he communicates.
JdpB42 has left #ocaml []
mfp has quit [Ping timeout: 240 seconds]
mfp has joined #ocaml
fraggle_ has quit [Ping timeout: 240 seconds]
fraggle_ has joined #ocaml
hto has joined #ocaml
avsm has joined #ocaml
edwin has joined #ocaml
The_third_man has quit [Ping timeout: 252 seconds]
The_third_man has joined #ocaml
avsm has quit [Quit: Leaving.]
ftrvxmtrx has joined #ocaml
ftrvxmtrx has quit [Read error: Connection reset by peer]
corecode has left #ocaml []
Snark has joined #ocaml
avsm has joined #ocaml
Cyanure has joined #ocaml
ikaros has joined #ocaml
avsm has quit [Quit: Leaving.]
voxel has joined #ocaml
reynir has joined #ocaml
Anarchos has joined #ocaml
avsm has joined #ocaml
voxel has quit [Ping timeout: 260 seconds]
Genius_Kiwi has joined #ocaml
voxel has joined #ocaml
voxel has quit [Client Quit]
voxel has joined #ocaml
voxel has quit [Client Quit]
voxel has joined #ocaml
voxel has quit [Client Quit]
voxel has joined #ocaml
zorun has quit [Quit: leaving]
avsm has quit [Read error: Connection reset by peer]
avsm1 has joined #ocaml
zorun has joined #ocaml
voxel has quit [Quit: leaving]
voxel has joined #ocaml
lpereira has joined #ocaml
lpereira has quit [Remote host closed the connection]
voxel has quit [Quit: leaving]
Genius_Kiwi has quit [Quit: Lost terminal]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]