Giter Site home page Giter Site logo

Comments (6)

iluuu1994 avatar iluuu1994 commented on August 25, 2024 1

This is mentioned in the RFC too:

A nullsafe function call syntax ($callableOrNull?()) is also outside of scope for this RFC.

from php-src.

iluuu1994 avatar iluuu1994 commented on August 25, 2024 1

@heiglandreas I wouldn't mind keeping this around as a feature request. But do note that I'm not sure this syntax is feasible due to the aforementioned lookahead problem.

from php-src.

iluuu1994 avatar iluuu1994 commented on August 25, 2024

$foo?() is not supported syntax. It's also ambiguous (without lookahead) because of $foo?(expr):(other_expr).

from php-src.

bwoebi avatar bwoebi commented on August 25, 2024

switch ($expr) { case $var?(2):foo: do_things(); } is fundamentally ambiguous here anyway, independently of lookahead. Is $var?(2) (the nullsafe fcall) the case expression and foo:do_things() the body (a goto label and a function call), or $var?(2):foo (a ternary with foo constant in else part) and do_things() the body?

from php-src.

iluuu1994 avatar iluuu1994 commented on August 25, 2024

Right. Some other languages do $foo?.() for syntax to avoid the ambiguity.

from php-src.

marc-mabe avatar marc-mabe commented on August 25, 2024

Right. Some other languages do $foo?.() for syntax to avoid the ambiguity.

Or $foo?->() to be more PHP like (this should allow $foo->() as well for consistency), which makes it end up in two different short style variants doing the same thing :/

Another option would be to make the callback argument of call_user_func[_array] nullable. Not as nice/readable as native syntax but an option.

from php-src.

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.