Go back up to my homepage.
Meme
Purpose
Meme is a language design I've been thinking about, it's
a hybrid of pascal and C, with bits from a few other
languages tossed in. The main thing is that expression
syntax is from C, while declaration syntax is from Pascal.
One design goal I'm trying to achieve
is to keep the language easy to parse, hopefully LL(1).
What's wrong with C declarations?
Small example program
Rough BNF Grammar
Ideas
-
The declarations look like pascal, but the statements and
expressions are just like C.
-
Member selection via '.' is smart, dereferencing is added
automatically in this case, and no '->' is needed.
-
Uses modules with interface/implementation seperation (Delphi),
there are no seperate header files.
-
Labeled loops, with labeled break/continue statements. (perl)
-
All constructs: if, switch, for, while, etc. require braces,
no dangling else problems. (perl)
-
Each identifier, when first introduced, is preceded by a
keyword (const, var, function, or type) that indicates what
is happening with that new symbol.
-
Each block opens a new scope (as in C), and variables can be
declared at any point in a function body (C++) using 'var'
or 'const'.
-
As a '0x' prefix defines a hex constant in C, '0b', '0o',
and '0d' will define binary, octal, and decimal constants
in a similar fashion. (decimal being the default if no prefix
is supplied.) (scheme)
-
Similarly, character escape sequences in strings and char constants
will allow these bases also using: '\b', '\o', '\d', and '\x' as
the prefixes. The current C meaning of '\b' as backspace, will
be available as '\h' (suggesting ctrl-H).
-
Classes are always dynamically allocated. (Delphi)
-
Classes provide no guarentee of data member ordering, for that
you need to use the struct type. A class will reorganize
data members to provide the tightest packing possible while
maintaining alignment requirements.
Ideas for the Future
-
The compiler could optionally accept unicode source code, allowing
identifiers in programs to be in other languages, or greek symbols,
or whatever.
-
Default memory allocation could be chosen on a class-by-class
basis, with one option being to garbage-collect instances of
that class, while other objects could still be heap-allocated.
-
Can also request dynamic allocation to occur on the stack,
with the object being automatically freed when you leave
that scope. (C - as alloca function)
Go back up to my homepage.
Mail me at: flisakow at spf-15.com