Giter Site home page Giter Site logo

Comments (9)

ankushdesai avatar ankushdesai commented on August 25, 2024 1

response = (status = ST_SUCCESS);
should be
response = (status = ST_SUCCESS,);
to indicate that its a tuple.

Sorry for this weirdness :)

from p.

ankushdesai avatar ankushdesai commented on August 25, 2024 1

We should mention this in the language manual ...

from p.

shazqadeer avatar shazqadeer commented on August 25, 2024 1

Is there a fundamental reason for this weirdness or just laziness in the parsing :-) ?

from p.

shazqadeer avatar shazqadeer commented on August 25, 2024 1

It looks like P is in elite company. Rust takes the same approach. See the code on lines 42 and 43 here.

I suppose explaining the issue in the documentation should be adequate.

from p.

ankushdesai avatar ankushdesai commented on August 25, 2024

There isnt an easy way to distinguish between a named tuple value (with single field in it) and parenthesis around a value: basically, we need the comma for the parser to distinguish between (5) and (5,) first is a value 5 and second is a tuple with one element 5 of type int. Not sure how to fix this without changing the way we represent tuple values. Any suggestions :)

from p.

ankushdesai avatar ankushdesai commented on August 25, 2024

Haha. Thanks for this pointer. Now people will no longer complain, as we can say we are same Rust ;). Elite club.

from p.

fintara avatar fintara commented on August 25, 2024

Thanks, it works!

Just to mention, such syntax can be seen in Python code too - so it's not that weird, one just has to remember about it. 😅

from p.

shazqadeer avatar shazqadeer commented on August 25, 2024

But I still find it weird that the error is reported in the parsing stage (and the error message is not helpful either). I would have expected parsing to succeed but type checking to fail with a better error message.

from p.

ankushdesai avatar ankushdesai commented on August 25, 2024

@shazqadeer the parsing fails response = (status = ST_SUCCESS); as in this case (status = ST_SUCCESS) gets parsed as an assignment statement and we then the parser starts complaining, I need to think about how this can help fixed.

from p.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.