Re: Pass by Reference

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

But this isn't how Euphoria works. One of the reasons for this is because it's important to match the number of parameters in the function call.

The parser knows how many values are expected to be passed in, and if they don't match it's an error. The parser knows this because the syntax of a function call parameter list reflects the intent.

Except that we do have optional parameters now, so there is some flexibility.

dcuny said...

I also think the syntax in the function call should match the return statement, and not "silently discard" the "extra" values. Instead, it should explicitly specify the values to be dropped:

I'm a little confused by this stuff. You're using the "naked" syntax here, which we don't use. In our implemented syntax, there's a big hint, I think, that you're discarding stuff. IOW:

a = foo() 

Nothing being discarded (unless the user does it explicitly later).

{a,?,c} = foo() 

This time, b got discarded.

{a} = foo() 

Everything after a is gone. We don't know how much by looking, but the braces are a hint that we're getting a sequence back and only keeping the first element (which could be all there is).

dcuny said...

Without this, the interpreter would have to guess what the intent of this is:

That, I think, is a major drawback to your proposed "naked" syntax.

dcuny said...

Behind the scenes this can be implemented as exactly the same functionality.

But by making the syntax explicit, the result is a lot safer, because the syntax reflects the intent, and catches bonehead errors.

Now I'm really confused. The naked stuff seems to make things implicit. It seems pretty explicit the way it is right now. I suspect I'm not getting what you're trying to say.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu