I welcome the change. I only use the compiling variable to create executables after building a working script anyway. I comment out the "if compiling" lines during maintenance and bug fixes and then uncomment them again to make an executable to put out on the server.
Eddie Rucker
Director of Institutional Research
Blue Mountain College
________________________________________
From: pure...@googlegroups.com <pure...@googlegroups.com> on behalf of Albert Graef <agg...@gmail.com>
Sent: Sunday, April 8, 2018 6:43:38 PM
To: pure...@googlegroups.com
Subject: [pure-lang] Batch compilation
Hi everybody,
I'm currently reviewing the way Pure does batch compilation (cf. https://agraef.github.io/pure-docs/pure.html#batch-compilation). Right now the batch compiler (`pure -c`) just executes the script, evaluating toplevel expressions and global variable definitions as usual, in order to support partial evaluation of a script at compile time (https://en.wikipedia.org/wiki/Partial_evaluation).
But that's simply too broad. E.g., if you compile a "Hello, world" script, it will print "Hello, world" also during batch compilation, which is not what you'd expect. There's the `compiling` variable to deal with this, but it's confusing and error-prone. It's really a kludge to tell the compiler something that it should handle on its own.
In order to make partial evaluation work, the only situation where code actually needs to be executed (rather than just generated) during batch compilation, are `const` definitions. So my plan is to confine execution during batch compilation to these, and get rid of the `compiling` variable. Of course, this implies that `const` definitions should only depend on other `const` values and can't be allowed to use values of `let`-bound global variables any more, but that seems like a good idea anyway.
This should make writing batch-compiled scripts much more straightforward, and it shouldn't limit the possibilities for partial evaluation. But of course it may well break some existing scripts.
Is anyone currently using the `compiling` variable at all? If not then I'll just go ahead and implement this, and fix up the affected scripts in the repository. Otherwise it would be interesting to see use cases which might become difficult with the changes sketched out above.
Albert
--
Dr. Albert Gr"af
Computer Music Research Group, JGU Mainz, Germany
Email: agg...@gmail.com<mailto:aggrae...@gmail.com>
WWW: https://plus.google.com/+AlbertGraef
--
You received this message because you are subscribed to the Google Groups "pure-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pure-lang+unsubscribe@googlegroups.com<mailto:pure-lang+unsubscribe@googlegroups.com>.
To post to this group, send email to pure...@googlegroups.com<mailto:pure-lang@googlegroups.com>.
Visit this group at https://groups.google.com/group/pure-lang.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pure-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pure-lang+unsubscribe@googlegroups.com.
To post to this group, send email to pure...@googlegroups.com.
Visit this group at https://groups.google.com/group/pure-lang.
For more options, visit https://groups.google.com/d/optout.