Re: Pass by Reference

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

Just off the top of my head:

,v = value("1234")
(even defaulted_value() and get() can return a two-part sequence)

Sorry, I must not have been clear about this.

Similar to the de-sequencing operation, you don't need to use the value - you just need to have the count match.

So I would expect the following to be legal if value passed back two values:

?,v = value("1234") 

But it doesn't - it returns a sequence. Changing how value() behaves at this point would break a lot of code, so I don't see an easy way to do this without the de-sequence operator.

What I'm asking for is a level of compile-time safety. Obviously, there's no way to know the number of parameters that are being passed back with a sequence until runtime. I assume that with 4.0 you are (supposed to) be able to handle this with:

{?,v} = value("1234") 

Similarly:

i,,, = int_to_bytes(999) 

should be valid as well... If int_to_bytes actually passed back two values.

The distinction I'm trying to make is that a function has the option of passing back multiple values. You'd only do this for the purpose of additional compile-time safety.

Or maybe I'm misunderstanding that you'd like the comma syntax with backward compatibility? For that, I'll go back to my initial point: you're still only returning a single value under the old system.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu