Re: Pass by Reference

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

I think I'd like there to be something else when returning like this to highlight that something different is happening. Maybe square brackets:

I disagree for a number of reasons. (Of course, that doesn't mean I'm right blink).

First, there's no need for adding square brackets. The syntax is already distinct enough for humans and compilers to recognize. Language like Lua and Python already demonstrate that.

Second, it breaks the existing idiom. We already have:

x = foo() 

Adding a comma extends the existing syntax:

x, y = foo() 

Whereas using the square brackets forces the user to use a new syntax without any obvious value.

After all, if you wrote by mistake:

x = foo() 

At compile time, the parser is going to throw an error like:

Error: Return count mismatch: foo() returns 2 values, but only assigns 1 
x = foo() 
So it's not going to be a very subtle bug.

Third, it uses an existing feature of syntax in an unrelated way. The square brackets already have a semantic meaning in Euphoria. Now you're overloading them with a new, unrelated meaning.

Hrm... I wonder why Creole things this paragraph needs to be indented.

Anyhoo, I think I'm going to take back my statement about how call_func() should operate. Given that the parser doesn't let the code compile if there's a mismatch, and call_func() throws an exception if there's a parameter length mismatch, I think the parameter count match should be enforced at runtime - that is, the left and right sides should be equal.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu