Re: What's new in 2.5?

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

Christian Cuvier wrote:
> 
> Yes, the structure is brand new. But what about functionality?
> 
> The only item I heard about is the cleanup handler. Nice improvement, even 
> though optional resume will be still missing :(
> 
> I had posted a wish list a couple years ago, most of which doesn't appear to 
> make its way in. The most important for my programming are:
> - local include (make an identifier visible to the including file only)

This is already in the language. Any non-global identifier declared
in an include file, and not inside a routine, is visible to the 
routines in that include file and nowhere else.

> - Allow PBR in routines, using some easy to spot syntax so that the 
> possibility for a var to be modified is not unpredictable;

This is very unlikely to happen. RDS is philosophically opposed to PBR.

> - Negative index tin strings;

We have been promised the '$' symbol that when used within [] represents
the length of the sequence.

   a = b[$]  -- get the last element
   c = b[$-1 .. $] -- get the last two elements.

> - call functions as procedure when they modify their first arg, so that
> 
> someMeaningfulLongName=append(someMeaningfulLongName,something)
> 
> may become
> 
> someMeaningfulLongName=append(_,something)
> or
> someMeaningfulLongName.append(something)
> or
> append(someMeaningfulLongName,something)

This would be nice syntactic sugar as it is such a common idiom in Eu.
 
> - Something I had not mentioned before: assume i+3 falls of the valid indexes 
> of sequence s. The current behaviour is that
> 
> if s[i+3]<3 then...
> 
> crashes as the bound check fails. But no logical condition holds true when 
> some of its args doesn't exist. As a result, it would be much simpler to code 
> if any such test quietly returned false.
> 
> Thus, we'd have, whenever x doesn't exist: x<y = x=y = x>y = 0. Not a problem,
>
> as x doesn't exist...

A guaranteed source of bugs, for sure. 

One could however use a function to check index validity before using.
Like ...

  if valid(s,i+3) and s[i+3]<3 then..

  if valid(s,{b,c}) then
       a = s[b..c]
  end if

where 'valid' is defined as ...

 function valid(sequence s, object x)
   if integer(x) then
       return x >= 1 and x <= length(s)
   end if
   if length(x) = 0 then
       return 1
   end if
   if x[1] >= 1 and x[1] <= length(s) and valid(s, x[2..$]) then
       return 1
   else
       return 0
   end if
 end function

-- 
Derek Parnell
Melbourne, Australia

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

Search



Quick Links

User menu

Not signed in.

Misc Menu