Last Element Notation

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

Robert,
AAARRRGRGGRRGGR!!!!

Please, please, reconsider some syntax notational assistance for accessing 
the last element in a sequence!

The current piece I'm working on often needs to reference the last element 
of a sequence, and often that is a deeply nested sequence. This causes the 
program code to become VERY VERY *&%$ at &!* at ^ unreadable. Sure, I can write 
some neat routines that do this but I'm trying to avoid the overhead 
(however bloody slight) of a routine call.


So that this ...

FB_Content[lBuffer][lLine] = FB_Content[lBuffer][lLine][1..lCol-1] &
                              pText &
FB_Content[lBuffer][lLine][lCol..length(FB_Content[lBuffer][lLine])]

can become something like ...

FB_Content[lBuffer][lLine] = FB_Content[lBuffer][lLine][1..lCol-1] &
                              pText &
                              FB_Content[lBuffer][lLine][lCol..$]

or even better, a couple of built-in routines...

FB_Content[lBuffer][lLine] = insert(FB_Content[lBuffer][lLine], lCol, 
pText)

and to simplify the extremely common idiom of removing the last element...

         if equal(pText[i][$], '\n') then
             pText[i] = remove_right(pText[i], 1)
         end if

instead of the hard-to-read ...

         if equal(pText[i][length(pText[i])], '\n') then
             pText[i] = pText[i][1..length(pText[i])-1]
         end if

Its little things like this that make Euphoria so frustrating, when the 
solution, from the point of view of your customers, is so simple. Please 
help us.

-- 
cheers,
Derek Parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu