Re: A question about certain language features

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ed Davis wrote:

<snip>
> 1) Variables can not be initialized when declared, but
> rather, must be initialized via an assignment statement.
> Based on other languages, this seems like one of those
> convenience type issues.  Is there some programming
> philosophy that says that an initialization in a declaration
> is a 'bad thing'?  What is the 'bad thing'?  I also note
> that standard Pascal does not allow variables to be
> initialized when they are declared.
>
> 2) No support of call by reference.  I understand that call
> by reference can lead to unexpected side-effects, but since
> changing global variables in a subroutine seems to
> essentially cause the same problem, I don't understand this
> omission.
>
> 3) No support for local constants.
</snip>

Only Rob can truly answer this, but I feel like speculating:

1. I share Ed's puzzlement about initialzion on declaration from a
programmming style stanpoint.  Dissallowing it simplifys the parsing of
declarations.

2. Call by reference is dangerous, as is assigning to a global variable.
But when your are assigning to a global variable, you know that you are
doing it--when you pass a parameter to a function written by someone else
(perhaps in a shrouded library) do you know that you a doing it?  In VB, you
don't know but assume so as ByRef is the default--even then without the
source or the good documentation that never exists in the real world you
don't know what the side effect will be.  So even if the fuction call syntax
required you to declare that a parameter you were passing was by reference,
there would be more uncertainty that in the global variable case.

OOP languages pass (objects) by reference, but what can be done to the
reference (object) is restricted to the operation of the object's methods.
Unexpected side-effects are less likely (though certainly possible).

3. I'm not sure about why this is dissallowed.

A factor that Rob must have considered--the more features implemented in the
interpreter, the bigger and slower the interpreter gets.  While any of these
features may be cheap in this regard, all the various proposed features
collectively are expensive.

>From his own writing, I gather that Rob's philosopy is "if it isn't
essential, leave it out."  Early versions of Eu didn't even have "for" --
all looping was done with "while", which is sufficient -- but for loops make
such clear code when used appropriately and were desired by a huge portion
of Eu users that Rob felt adding this feature was in order.

In general I agree with Rob's philosophy as I understand it.  Euphoria is so
flexible that you can do almost anything in libraries rather than the core
language.

Thank you, Ed, for an exellent though-provoking question.

-- Mike Nelson

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu