Le vendredi 19 juin 2020, 16:12:26 CEST Wink Saville a écrit :
> Docstrings and curvfmt and would be a great additions to curv.
I’m happy you like the idea of docstrings too :D
> I'd like to be able to write curvfmt in curv, but that leads to making
> curv a general purpose language.
I feel like this “general purpose” thing collides with a fundamental
feature of curv: it is *purely* functional. Unlike other general purpose
programming languages it can draw inspiration from, like Scheme or ML
(which explicitly resort to side-effect as soon as any I/O is needed: and
you soon do).
This characteric usually creates problems as soon as you want to do I/O,
and you usually want to because you usually write programs to interact
with them, or to make stuff in your environment… interacting with files is
an example of that (and it is something you’d need to write curvfmt in
curv).
The smart thing of curv being that with it being a DSL, his *return value*
*is* the I/O. This is a really interesting and beautiful concept.
It could work on files too: imagine a domain-specific functional language
“filer” that take files, or hierarchy of files, as input/arguments, and
returns file(s) or a hierarchy of files as a “return value”… and, not the
“filer” programs, but the engine of it, would open the files and write them,
possibly overwrite… From the “filer language”, in “filer” programs, you
would have nothing to open or write files, but you could read the content
of arguments, and makes new “files” object to return. Then the language
engine “filer” would do the I/O. You could invoke it as “filer program.filer
-i input-file -o output-file” and it would perform what you want, possibly
you could do “-i same-file -o same-file” to overwrite a file hierarchy,
simulating an in-place modification… except it would be implemented using
functional programming.
But a such language wouldn’t be curv anymore. Curv is made so that to
compile to GPU and output shapes, not files. Curv is made to —depending on
what you ask it on command-line interface— automatically open this window
that shows you the curv program return value visually, but is not made to
have an “output file” set from the command-line, to write the return value
to a file (or yes, it has, but it will only write shapes, not ASTs,
strings, curv programs, etc.)… I mean, it has special options to output
other kind of shapes (mesh and voxels), but it’s not the same, is it?
> Doug is that something you want to do?
According me that abids to fundamentally change the language, isn’t it?
I don’t know what Doug may want, but to me, the way curv is designed, if
that changed, it wouldn’t be curv anymore.
At least if it involves adding side-effect I/O operations.
But… maybe extending the curv concept of I/O / return-value to more than
shapes would be an interesting experiment? for strings to begin (it would
be for a single file). That would at least provide functional “output” of
more kinds… then I start wondering if it should be regretted that “file”
and “include” eval their argument, instead of considering it as a string…
because then a separate function “file-as-string” would be needed…
Then for several files, a “separate datatype” (it could as well be a
composition, such as a record of paths) would be needed, and whenever
returned should be written accordingly to the filesystem… how does that
seem to you Doug?