Re: Re: Creating an experimental syntax

From: Date: Sat, 17 Oct 2009 17:38:47 +0000
Subject: Re: Re: Creating an experimental syntax
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-45837@lists.php.net to get a copy of this message
Hello, On Sat, Oct 17, 2009 at 4:22 PM, Rune Kaagaard <rumi.kg@gmail.com> wrote: > Dear Internals > > So I'm making good progress and found out that making simple syntax > changes is quite easy. What I currently got working can be seen here: > > http://code.google.com/p/php-alternative-syntax/source/browse/trunk/scripts/kitchensink.php. > > However, making functionality changes still baffles me. I changed the > "return" keyword to "<-", and I would like to automatically add a > return on the last line of a function. So that the following PHP code: > > <?php > function foo() { >  $x = 2; >  $x * 2; > } > ?> > > would return an int with a value of 4. > > How should I attack this problem? This will be tricky to implement as you've to check if the last statement of the function represents a value or not as Scala does, and a lot of statements in PHP have no values: switch/while/for/if... So function a() { if(true) .. else ..; } would have to implicitely return null, since if() is not a value. > > Thx a lot! > Rune Kaagaard > Denmark > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch

« previous php.internals (#45837) next »