Re: Pass by Reference

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
jimcbrown said...
petelomax said...

I've only just grasped the full extent of the call_func() issue and yes that gets horribly messy because it has to drag all this stuff out of the parser and right into the runtime/translator, for very little benefit.

If desequencing simply mandated that the LHS and the RHS must have the same number of elements, or else it's a run-time error, then simply using desequencing with call_func() would be able to catch most of the errors that the parser's multiple assignment scanner would. Hmm.

If desequencing were just the same as multiple assignment then yes,

I guess this depends on the implementation.

petelomax said...

I take it for granted that in desequencing (playing with sequences) this remains perfectly valid

p = {1,2,3} 
{i,j} = p 

Let's take that for the sake of argument.

petelomax said...

However, with multiple assignments (function results)

{i,j} = call_func(...)  -- (oi, there be 3 values there, mate) 

It's ugly (and I mean really ugly), but it's possible to make the desequencing operator aware that the value comes from a call to call_func(), and behave differently in that case. So then,

{i,j} = p -- ok, ignore the third 
{i,j} = call_func(...)  -- run-time error 
 
function identity(object o) 
return o 
end function 
 
{i,j} = identity(call_func(...))  -- a trap! no run-time error!!! 
petelomax said...
p = call_func(...)      -- (oi, where's me multiple assignment) 

You got me. This one I don't know how to handle....

petelomax said...

Then whether it is desequencing (as above) or the semantically different multiple assignment (function results) must be dynamically determined; whether the routine being invoked contains a return 1,2,3 or a return {1,2,3} has to be known at run-time to determine whether it is an error or not. That is the bit I am calling an awful lot of work for very little gain.

I hadn't even thought of this. I was thinking of ways to do it without having to dynamically determine the difference at run-time (by having it all turn into desequencing at run-time, and then adding some special cases to desequencing to make it look more like multiple assignment).

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

Search



Quick Links

User menu

Not signed in.

Misc Menu