Re: more idle thinking: SiMPL
- From: "BGB / cr88192" <cr88192@xxxxxxxxxxx>
- Date: Tue, 22 Sep 2009 22:29:16 -0700
"BGB / cr88192" <cr88192@xxxxxxxxxxx> wrote in message
news:h9buac$vct$1@xxxxxxxxxxxxxxxxxxxx
this is just a few thoughts I have been thinking on and off recently, me
faced with the sort of "slippery slope" of extreme complexity I have faced
myself with over the past few years.
I will not claim at this point any particular intention to implement
something like this.
updates:
SiMPL is too much like SiMPLE, which is a language which already exists;
SMPL at least would less likely cause confusion.
I am thinking of an odd piece of syntax:
<name> '(' <exprlst> ')' <block>;
also:
<name> '(' <exprlst> ')' <expr>;
which could be used to extend the syntax in a way both context independent,
and fairly general purpose. similarly, function call syntax could be used
for other similar extensions.
semantically, this would mean a slight overloading though, as:
Foo(x, y);
could be either a function call, or something more along the lines of:
Foo<x, y>;
y=cast(int) sqrt(5);
another pondered thought was to allow ';' as a secondary grouping operator
(within things like args lists).
foo(a, b; c, d;);
which would cause a,b and c,d to be grouped into single items.
the other possibility is to allow parenthesis to be used for grouping:
foo((a, b), (c, d));
as noted, there will be no syntactic difference between type names and
expressions.
by extension:
"*int", if the pointer extension is supported (as opposed to "int *"), since
the '*' would in this case be parsed as a prefix operator.
function foo_memcpy(dst:*void, src:*src, size:int):void
{
var pa:*byte, pb:*byte;
int i;
pa=dst; pb=src;
for(i=0; i<size; i++) pa[i]=pb[i];
}
by extension (assuming this syntax used for classes / ...):
class(Foo, Bar, IBaz) {
var x:float, y:float;
function Foo(x:float, y:float)
{
this.x=x; this.y=y;
}
}
treatment of ';' could be a little more flexible than in C family languages,
where it may be safely omitted in cases where it is non-ambiguous.
<name> '(' <exprlst> ')' <block>
<name> '(' <exprlst> ')' <expr>
no ';' being needed if these appear as statements, since the end of an
expression is typically self-deliminated.
however, there are certain cases where this is not the case, such as when
the next statement would begin with a prefix operator (would matter in the
'expr' case), which would essentially require the ';' to avoid being
ambiguous.
note:
<expr> '(' <exprlst> ')' <block>
<expr> '(' <exprlst> ')' <expr>
will presently be considered invalid (where expr!=name), since these would
likely make an unreasonable headache for the compiler (AKA: not possible to
disambiguate at compile time).
':'<type> could almost be made a general-purpose syntax, apart from the
issue of ambiguity in the case of switch/case (could be hacked if needed,
namely in that case would essentially disable ':', similar to how args-lists
in C essentially disable the comma operator...).
also possible:
var(static) x:int; //makes modifiers non-special
function(static) foo():void {}
//natural extension, but creates a syntax problem if ES/JS style closures
are supported.
function(x:int, y:int):int { return(x*x+y*y); }
ES-style closure.
in some of my past script languages though, I had instead used 'fun' for
closures:
fun(x:int, y:int):int x*x+y*y;
problem:
this requires either:
making 'fun' a part of the built-in syntax;
making "':' <type>" general-purpose syntax (leading to a 'case'
special-case).
granted, all this is a little "squirrely", but it would allow pulling off
the core goals:
providing for both context independent parsing and extensibility.
compile-time semantics is another issue, since, more so than many other
languages, a little more work will be required to make sense of the ASTs.
note that, in my thinking, "import" would be mandatory prior to using any
such features.
this is because, even though these features are likely to be built into the
compiler, the import will essentially tell the compiler to make them
"visible" (beyond its use of importing module scopes).
granted, I will not specify at this point whether the language would include
any sort of macro facilities, however, if provided, they would most likely
be as an extension.
or such...
.
- References:
- more idle thinking: SiMPL
- From: BGB / cr88192
- more idle thinking: SiMPL
- Prev by Date: more idle thinking: SiMPL
- Next by Date: Re: more idle thinking: SiMPL
- Previous by thread: more idle thinking: SiMPL
- Next by thread: Re: more idle thinking: SiMPL
- Index(es):
Relevant Pages
|