Re: Ideas for next Eu

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

I'd like to contribute my own 1/50th of a dollar to this topic...

One continuing source of frustration for me is Euphoria's inability to deal
intelligently with returning more than one value from a function. Hence the
following annoyance, in two versions:

-- version 1: sensible variable names, inefficient code
sequence pos
integer line, column
 pos = get_position()
 line = pos[1]
 column = pos[2]
 -- do whatever
 position(line, column)

-- version 2: more efficient execution, variable names less than helpful
sequence pos
 pos = get_position()
 -- do whatever
 position(pos[1], pos[2])

This, to me, is one of the glaring inconsistencies in Euphoria's otherwise
very self-consistent language design. We can send multiple variables to a
routine, but can only receive one variable back.

Now, obviously, in most languages this is what we're normally stuck with.
But those languages don't have a data type like the sequence, and you'd
think Euphoria would have been designed to take advantage of that. Instead,
we as Euphoria programmers are forced to create receiving temp sequences
which we then have to:

1) "unpack" into variables with more sensible names, or
2) we simply subscript the temp sequence, at the cost of understandability.

I suppose a better variation on #2 would be to create intelligible constants
for subscripting of the receiving sequence, like so:

constant POS_LINE = 1, POS_COLUMN = 2
sequence pos
 pos = get_position()
 -- do whatever
 position(pos[POS_LINE], pos[POS_COLUMN])

But, really, it would be much more efficient and intelligible (IMO) to be
able to do the following:

integer line, column
 {line, column} = get_position()
 -- do whatever
 position(line, column)

Ahh, now *that's* more like it! It makes perfect sense when you read it,
without requiring the need for klunky subscripting, additional constants, or
manual "unpacking" of the values. "Elegance," if you like.

The current way Euphoria forces us to do this is annoying, unsightly,
potentially confusing, and could easily be done transparently by the
interpreter, as I have demonstrated above. I hope this idea (or something
like it) is being seriously considered for implementation in Euphoria's
future.


Thank you,
Gabriel

----------
Nothing is so remote from us as the thing which is not old enough to be
history and not new enough to be news.

G.K. Chesterton
----------

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

Search



Quick Links

User menu

Not signed in.

Misc Menu