1. More Wishlist Things

G'day all

While we're talking about wishlist items, I'd like to see some
support for a shorthand notation in Euphoria, something like the
#define used by C/C++. It would be nice if something like the
following:

<longhand>
for i = 1 to length(mainseq)
   mainseq[i][21] = mainseq[i][5] + mainseq[i][15]
   mainseq[i][22] = mainseq[i][8] - mainseq[i][9]
   mainseq[i][23] = (mainseq[i][12] / mainseq[i][13]) + mainseq[i][5]
   <lots more of the same>
   if i != 1
      mainseq[i][54] = mainseq[i-1][7] + 2
   else
      mainseq[i][54] = 0
   end if
end for
</longhand>

could be cut down to something like:

<shorthand>
for i = 1 to length(mainseq)
   with mainseq[i]
      [21] = [5] + [15]
      [22] = [8] - [9]
      [23] = ([12] / [13]) + [5]
      < lots more of the same>
      if i != 1
         [54] = mainseq[i-1][7] + 2
      else
         [54] = 0
      end if
   end with
end for
</shorthand>

I know this could be done with a preprocessor, and I also know
that the "with..end with" syntax has been linked with namespaces,
but it still would be a nice thing to have, whatever the syntax.

Regards
Tony

new topic     » topic index » view message » categorize

2. Re: More Wishlist Things

On Monday 25 June 2001 00:50, Tony Bucholtz wrote:

> G'day all
>
> While we're talking about wishlist items, I'd like to see some
> support for a shorthand notation in Euphoria,....

> <shorthand>
> for i = 1 to length(mainseq)
>    with mainseq[i]
>       [21] = [5] + [15]
>       [22] = [8] - [9]
>       [23] = ([12] / [13]) + [5]
>       < lots more of the same>
>
> I know this could be done with a preprocessor, and I also know
> that the "with..end with" syntax has been linked with namespaces,
> but it still would be a nice thing to have, whatever the syntax.
>
> Regards
> Tony

Actually, there's no reason I can see that the same syntax couldn't 
be used for both. (namespacing and 'structures').

While your shorthand above would be a big improvement, I would really 
like to see it implemented fully: e.g:

    with customer [ i ] do
          NAME = "Joe Blow"  -- not [NAME], just NAME
          ADDR = "1234 Fifth St."
          with TXN [ 4 ] do
                 ITEM = "Dog food"
                 AMT = 2.99
          end with 
     end with

Which would be a welcome relief  from the abominable:

customer[i][NAME] = "Joe Blow"
customer[i][ADDR] = "1234 Fifth St."
customer[i][TXN][4][ITEM] = "Dog food"
customer[i][TXN][4][AMT] = 2.99

When you have a bunch of nested fields, this kind of thing gets 
error prone,  and not only your code, but Euphoria as well, looks bad.

Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu