Re: A question about certain language features

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

On Monday 11 February 2002 05:39 pm, Ed Davis wrote:
>
> tone.skoda at siol.net wrote:
> > Euphoria is almost perfect programming language as it is now.
> > It only needs a simple OOP addition.
> > Of course, debuger and editor with IDE also are missing, but that is not
> > part of language itself.
>
> I appreciate your feelings, but I'm not sure what this has
> to do with my original message/questions?
>
> > Why call by reference, becuase VB has it?
>
> I've never used VB.  I have used C, C++, Pascal, Modula 2
> and Oberon, all of which feature call by reference (well, in
> C you have to use pointers, but it amounts to the same thing
> in actual use).

Call-by-reference isn't used much, but when it is, it makes code 
both simpler and clearer: Compare:

swap(A,B) 

with our available alternative:
object tmp
  tmp = A
  A = B
  B = tmp

> > It is complicated feature, I don't need it.

Not at all complicated. And it doesn't cause errors, because (in Pascal, for 
example) it must be specifically and consciously  enabled in the function 
header.

> > Variables can not be initialized when declared, that is ok.
>
> That may be.  But I did not ask if it was 'ok', I simply
> asked why it is not allowed.  Is initializing a variable
> when it is declared a 'bad thing'?  It is supported in other
> languages I have used, and so I was wondering why not in
> Euphoria.

If it is a bad thing, then does that not make constant declarations equally 
bad? 

> > Local constants are really not needed.

Nothing, other than a handful of assembler instructions, are really needed.

Everything else is either for convenience or for clarity.
Local constants make for clearer, less buggy code.
The alternative, which we have now, is to declare them as variables,
assign to them, then hope we don't accidently change the value somewhere 
in the routine. And the only way to know whether that variable is used as 
a variable or as a constant is to read the entire routine. How does that 
contribute to clarity or convenience?

<snip>

> And to make sure I'm clear - I'm not asking for these
> features to be added to Euphoria.
>
> For instance, I can see why the author would not choose to
> add a goto to Euphoria.  Many programmers realize that
> goto's, used unwisely, can cause hard to
> follow/maintain/prove correct code.
>
> I'm simply trying to understand if in general the author
> feels that call by reference, variable initialization on
> declaration, and locally declared Euphoria constants are bad
> things, or would lead to poor programming style, or what
> have you.
>
> If I know why these things are not allowed, who knows,
> perhaps I will adopt this style for my own use in the other
> languages I program in.

Other than the goto, I've never seen any textbook that condemns 
these things. All that any of them can do is contribute to code clarity. 
As to why they're not in Euphoria, along with a number of other things 
which would add convenience while improving and simplifying code, 
only Rob can answer.

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu