Re: New bytecode assembly language to play with



Chapter33@xxxxxxx writes:

On 9 Apr, 20:08, Robbert Haarman <comp.lang.m...@xxxxxxxxxxxxx> wrote:
<snip>

However, C syntax does have its deficiencies. Thus, it is entirely
conceivable that you might come up with a better syntax. In my opinion,
many languages have.

Examples please? I'm very open to looking at other languages for
inspiration.

Almost any other language is an improvement to C (at least in terms of
syntax). While somewhat more verbose, Pascal has a more readable and
less ambiguous syntax than C. For more modern languages, look at SML
or Haskell.

One of the problems with C syntax is variable declarations. While
they are based on the simple idea of a type followed by a list of
variable names, this is not followed through, so parts of the type is
described at each variable name rather than as part of the type.
Compare C's "int *x[]", where the type is both to the left and right
of the variable, with SML's "x : int array ref", where the name and
type are clearly separated on each side of the colon. Yes, the SML
syntax is more verbose, but that is mainly due to lexical rather than
syntactic differences.

Interesting. I didn't expect to find someone who advocated declaring
functions within functions...it seems to me that having function code
only available within the scope of a single function to be a pretty
meaningless thing to do...how could you possibly benefit from
that?.....hmmm, ok, am I missing something, can you give me a good
example of when you would wish to use this feature and why it is
important?

Good reasons:

1. A locally declared function can "see" variables in the scope in
which it is declared. A globally declared function can only see
global variables (or parameters). This has several consequences:

- You don't need to pass information to a function through
parameters or global variables.

- When passing a locally declared function as a parameter, this
functional value can still refer to variables from its scope.
This allows much more powerful uses of functional values. If
you can, additionally, return the function outside its scope,
you can get even more powerful uses.

2. By declaring a function locally, you can limit its scope. You can
do the same with modules, but that is overkill in many cases.


Torben
.



Relevant Pages