Re: Discussion concerning [POLL] Sequences of types

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

Derek Parnell wrote:

> Juergen Luethje wrote:
> > Say we have something like
> >    names = {"Tom", "Mary", "Bob"}
> > 
> > If the new syntax is not restricted, then at least each of the following
> > would be syntactically correct:
> >    object names
> >    sequence names
> >    sequence of sequence names
> >    sequence of sequence of object names
> >    sequence of sequence of atom names
> >    sequence of sequence of integer names
> 
> Yes, they are all syntactically correct, but each has a different semantics.
> 
>   object names -- Can be assigned with anything.
>   sequence names -- Can only be assigned with a sequence.
>   sequence of sequence names -- Can only contain sequences.
>   sequence of sequence of object names -- same as above.
>   sequence of sequence of atom names -- Can only contain sequences, which
>                                       -- can only contain atoms
>   sequence of sequence of integer names -- Can only contain sequences, which
>                                       -- can only contain integers

I know that each one has a different semantics, but that's not my point.

> If this is too much for some people to grok then maybe a simplified 'type'
> alias
> might be useful.
> 
>    type word_list (sequence of sequence of integer)
>    end type

We do not need an alias mechanism if we do things properly in the first
place. Only allowing the new syntax in type definitions like this was
the core of Pete's proposal.

> > and maybe even
> >    object of sequence names
> >    object of sequence of object names
> >    object of sequence of atom names
> >    object of sequence of integer names
> 
> Well, the above would not be valid

Maybe, maybe not. We can't know that for sure until it would be
implemented.

> as they don't start with "sequence".
> 
>  
> > or
> >    sequence of object names
> >    sequence of object of object names
> >    sequence of object of atom names
> >    sequence of object of integer names
> 
> However, 'sequence' by itself is already an abbreviation for 'sequence of
> objects'.
> 
> > This is very confusing, especially for beginners, and has IMHO nothing
> > got to do with the spirit of Euphoria.
> 
> If its the wordiness that worries you then we can solve that with an alias
> mechanism.

One problem is that it can reduce redability. Things like
  object foo
  sequence bar
etc. can be read quickly and reliably at one glance. This is not the
case for variable declarations like above, especially since there are
_many_ different possibilities to declare the same variable.

Another problem is that it has a good potential to cause confusion.
Imagine a newbie who wants to declare 'names'. Which of the available
14 (or 18, that doesn't matter) options should s/he use?

> And exactly what is "the spirit of Euphoria"?

You know very well that it's not possible to give an exact definition of
it. However, there is something like that. You can call it the "core
principles of Euphoria" or something similar, if you prefer.

Certainly _not_ among the core principles of Euphoria is making things
unnecessarily complicated, confusing newbies, and providing lots of
different options for the same thing.

Actually one of Euphoria's principles is to reduce the number of choices
which the programmer has to made. This is what makes the language simple,
clean and good readable.

For everyone who is seriously interested in this matter, I can recommend
an interesting lecture by Prof. Barry Schwartz:
The Paradox of Choice - Why More Is Less (April 27, 1006).
[video, about 1 hour]
<http://video.google.com/videoplay?docid=6127548813950043200>

> > That's why Pete Lomax suggested to restrict the new syntax to the
> > definition of types. Then w'd have to create a user-defined type say
> > "word_list", and in our programs we just say:
> >    word_list names
> 
> Like the simplified alias syntax I suggested above?

Yes. Well, in the meantime Pete has replied himself.

> > I'm strongly against the introduction of the new type syntax without
> > this restriction.
> 
> I don't really think that this concept, which is used in other languages, is
> all that baffling to newbies and oldbies alike.

I don't know any other language that provides 14 or 18 different
possibilities for declaring the same variable.

Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu