What I meant is: why don’t keep *only* *curved parenthesis* (not squared
brackets). So it’s like lisp, ocaml, haskell, any programming language
with the « f(x) » notation, etc. ?
Le vendredi 6 décembre 2019, 00:03:24 CET Doug Moen a écrit :
> Sebastien has proposed a projectional editor for Curv, where the source
> code is stored in memory as a syntax tree, rather than as text.
Oh my god this is amazing, just like the old glorious days of lisp
programming environments :o before it died with GNU Emacs as the sole
survivor…
> The
> syntax tree can "projected" onto the display using a variety of
> syntaxes and representations, not just plain text, but text plus
> graphics.
I had exactly thought of this in the past (like “content/view separation”
and “stylesheets for programming languages”) :o that’s the first time I see
it mentioned anywhere else… do similar things already exist outside Curv
btw? Because I see a great patterns of good ideas united around Curv.
> What are the essential features of Curv's current text syntax that must
> be represented in that syntax tree, and what are the non-semantic
> features that can be left out? White space and indentation can be left
> out.
Well, you could “tab” stuff to improve readability *sometimes*. But that’d
better be done in the viewer.
As in regards to indentation, let me add something: do you know the
(indent n) declaration form in emacs lisp? It’s something you place in
function definitions, just after the docstring, so you indicate some sort
of “separation” after the nth argument. For instance, “map” has an
“(indent 1)” so all parameters are aligned… *but* the first (so you save
space on the screen). That way you semantically give an importance to
grouping of ordered arguments, so that indentation stays flexible and
semantically right… in an automated manner.
> The distinction between (a,b,c) and [a,b,c] doesn't carry any
> semantic meaning, so maybe it could be left out as well?
Did you separately used both for anything? why [] at first?
> The same questions arise when I think about writing a code formatting
> tool for Curv, which reformats Curv programs to use a standardized
> coding style. The output of a formatting tool would be a trial run for
> what a program looks like when formatted by the projectional editor.
> Any information that is thrown out by code formatting tool doesn't need
> to be preserved in the syntax tree of a projectional editor. Any
> features of the Curv syntax and grammar that aren't used in the output
> of the formatting tool are candidates for being deprecated.
These appears two separate questions for me. The advantage of storing
stuff as an AST is you don’t *have* to link it with a predetermined
graphical representation (so it could even improve accessibility,
ergonomy, etc.). So you wouldn’t *have* to says lists are like tuples in
haskell/ocaml/etc. and like function calling in C-like, or lists are like
C arrays, etc. you let that up to the user.
What’s great is then each one can have his own preferences on what
datatype is presented in what manner. So you wouldn’t need a textual
syntax, only a stylesheet (and standardized ways of binarily serializing
them (it could be a simple mmap of ram : not really portable but compiled
emacs do that at startup (it’s called unexec))). Then the user choose.
One cool stuff about current syntax is it *looks like* a lot like other
languages. You yourself proposed to borrow from modes for json or ocaml
for syntax highlighting and other mode-specific stuff for emacs and vim…
You see that can be useful. But not only for such shiny/fancy stuff: you
could imagine really small “programs” that could be both interpreted by a
C compiler and curv, or by javascript and curv, or by ocaml and curv…
without modification (using a subset of these). That may sound like crazy
but… think like “{\n#include "fixnum-array.csv"\n}" inside a C source code
file… it could work. You already suggested honestly to use it for syntax
coloring, why not further?
We could even imagine to do all the opposite of nowadays : instead of
writing in text, and getting it displayed as such, but parsed to be
executed, you could “write” it in binary with this editor, so that it’s
already PIC-serialized in such a way it would just work by being almost
only loaded into memory right away with mmap, and then you show that with
a stylesheet… and use that same stylesheet to generate a parser for this
language (if expressive enough a single definition can be used both ways:
for parsing and displaying).
Curv is C++ right… I’m wondering… did you think to make a declarative
parser?
> I've never been able to come up with a consistent set of rules for when
> to use (a,b,c) and when to use [a,b,c] in Curv programs, so as an
> experiment, I tried reformatting all of the examples to use the syntax
> [a,b,c] consistently, and it's fine. Nothing of importance seems to
> have been lost. This reduction in syntactic variability actually seems
> like an improvement, because now when I see a ( buried in the middle of
> an expression, I know it can only be used for grouping, it isn't the
> beginning of a list.
Oh, I see, parenthesis can already be used for something else…
Okay this is sad but understandable… You just you too want to distanciate
from lisp for easier reading…