# php7- dropping the $ from the variable name - rfc

- Thread: https://externals.io/message/40550
- Original archive: https://news-web.php.net/php.internals/40550
- Started by Ionut Gabriel Stan on 2008-09-18T18:30:37+00:00
- Messages: 17
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #40550 — Ionut Gabriel Stan — 2008-09-18T18:30:37+00:00

URL: https://externals.io/message/40550#40550

Actually, I somehow understand what he wants, considering we'll soon have lambdas and closures. I mean, in case of javascript a variable can hold as well a function as it can hold anything else. Anyway, I don't think this is the case for PHP. I do find it ugly to write $function(), but I guess I'll live with it as I did until now.

Cheers,
I. Stan




----- Original Message ----
From: Brian Moon <brianm@dealnews.com>
To: mike <mike503@gmail.com>
Cc: marius popa <mapopa@gmail.com>; internals@lists.php.net
Sent: Thursday, September 18, 2008 9:06:11 PM
Subject: Re: [PHP-DEV] php7- dropping the $ from the variable name - rfc

mike wrote:
> Personally I love the $. It makes it so much easier to identify
> variables. It's a single character. Can't see the need honestly to
> even bring this up.

+1,000,000.  Horrible idea.  *facepalm*

-- 

Brian Moon
Senior Web Engineer
------------------------------
When you care enough to spend the very least.
http://dealnews.com/

---

## #40551 — Alain Williams — 2008-09-18T18:38:55+00:00

URL: https://externals.io/message/40550#40551 · In reply to: #40550

> Actually, I somehow understand what he wants, considering we'll soon have lambdas and closures.  I mean, in case of javascript a variable can hold as well a function as it can hold anything else.
> Anyway, I don't think this is the case for PHP.  I do find it ugly to write $function(), but I guess I'll live with it as I did until now.

So if you drop the '$' the way that you call a function referenced in variable
'funref' is not:

	$funref()

but

	funref()

However: the PHP parser will take that to be a call to a function named 'funref'.
So you need to change the syntax to, perhaps, something like C:

	(funref)()

I can't see people understanding that.
Stick with what we have.

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h

---

## #40555 — Arvids Godjuks — 2008-09-18T19:09:29+00:00

URL: https://externals.io/message/40550#40555 · In reply to: #40550

Well, you can do that right now, PHP supports that for ages.

<?php
$myVar = 'print';
$myVar('Hello!'); // Outputs hello
?>

So lamdas realy do not change anything in this context. What they do is make
our life easier by making us able to live without create_function().

Anyway, removing $ is bad and people gave plenty of points for that. Here is
summary:
1). Break every application.
2). Break highlight.
3). Make almost imposible for parser to replace variables with their
contents in " " and HEREDOC constructions. Well, it can be done, but it will
make a huge slowdown and memory usage.
4). Adding $ before variable doesn't take any time for any experienced in
PHP developer
5). Variables are seen clearly in code.
6). Hey, you can use $ in JS too! It just works! :)

2008/9/18 Ionut Gabriel Stan <ionut.stan@yahoo.com>

> Actually, I somehow understand what he wants, considering we'll soon have
> lambdas and closures. I mean, in case of javascript a variable can hold as
> well a function as it can hold anything else. Anyway, I don't think this is
> the case for PHP. I do find it ugly to write $function(), but I guess I'll
> live with it as I did until now.
>
> Cheers,
> I. Stan
>
>
>
>
> ----- Original Message ----
> From: Brian Moon <brianm@dealnews.com>
> To: mike <mike503@gmail.com>
> Cc: marius popa <mapopa@gmail.com>; internals@lists.php.net
> Sent: Thursday, September 18, 2008 9:06:11 PM
> Subject: Re: [PHP-DEV] php7- dropping the $ from the variable name - rfc
>
> mike wrote:
> > […]
>
> +1,000,000.  Horrible idea.  *facepalm*
>
> --
>
> Brian Moon
> Senior Web Engineer
> ------------------------------
> When you care enough to spend the very least.
> http://dealnews.com/

---

## #40556 — troels knak-nielsen — 2008-09-18T19:25:07+00:00

URL: https://externals.io/message/40550#40556 · In reply to: #40555

On Thu, Sep 18, 2008 at 9:09 PM, Arvids Godjuks
<arvids.godjuks@gmail.com> wrote:
> Well, you can do that right now, PHP supports that for ages.
>
> <?php
> $myVar = 'print';
> $myVar('Hello!'); // Outputs hello
> ?>

Partly because I can't resist being smug, partly because it might
confuse someone, I have to point out that that example won't work,
because pint isn't a function. It would work with most everything else
though.

--
troels

---

## #40558 — Jordan Moore — 2008-09-18T19:47:23+00:00

URL: https://externals.io/message/40550#40558 · In reply to: #40556

On Thu, Sep 18, 2008 at 12:25 PM, troels knak-nielsen
<troelskn@gmail.com> wrote:
> On Thu, Sep 18, 2008 at 9:09 PM, Arvids Godjuks
> <arvids.godjuks@gmail.com> wrote:
> > […]
>
> Partly because I can't resist being smug, partly because it might
> confuse someone, I have to point out that that example won't work,
> because pint isn't a function. It would work with most everything else
> though.
>
> --
> troels
>
> --
> 
> 
>
>

You're right, "pint" isn't a function, and neither is "print".

;)

-- 
Jordan Ryan Moore

---

## #40563 — Dmitry Stogov — 2008-09-19T10:31:13+00:00

URL: https://externals.io/message/40550#40563 · In reply to: #40551

Alain Williams wrote:
> 
> 
> > […]
> 
> So if you drop the '$' the way that you call a function referenced in variable
> 'funref' is not:
> 
> 	$funref()
> 
> but
> 
> 	funref()
> 
> However: the PHP parser will take that to be a call to a function named 'funref'.
> So you need to change the syntax to, perhaps, something like C:
> 
> 	(funref)()
> 
> I can't see people understanding that.
> Stick with what we have.
> 

There is no difference between a function and a variable which holds a
closure in many languages (e.q. JavaScript, LUA, ...), so you don't need
any extra syntax rules.

function foo() {
}
foo();

var bar = function() {
}
bar();

It's not possible to make the same unification with PHP's $, however I
don't see a way to remove $.

Thanks. Dmitry.

---

## #40568 — Marcus Boerger — 2008-09-19T22:47:04+00:00

URL: https://externals.io/message/40550#40568 · In reply to: #40550

Hello Ionut,

  a Friend suggested to replace it with a Euro sign, so that PHP code gets
  worth more :-)

marcus

Thursday, September 18, 2008, 8:30:37 PM, you wrote:

> Actually, I somehow understand what he wants, considering we'll soon
> have lambdas and closures. I mean, in case of javascript a variable can
> hold as well a function as it can hold anything else. Anyway, I don't
> think this is the case for PHP. I do find it ugly to write $function(),
> but I guess I'll live with it as I did until now.

> Cheers,
> I. Stan




> ----- Original Message ----
> From: Brian Moon <brianm@dealnews.com>
> To: mike <mike503@gmail.com>
> Cc: marius popa <mapopa@gmail.com>; internals@lists.php.net
> Sent: Thursday, September 18, 2008 9:06:11 PM
> Subject: Re: [PHP-DEV] php7- dropping the $ from the variable name - rfc

> mike wrote:
> > […]

> +1,000,000.  Horrible idea.  *facepalm*

> -- 

> Brian Moon
> Senior Web Engineer
> ------------------------------
> When you care enough to spend the very least.
> http://dealnews.com/


> -- 
> 
> 


>       




Best regards,
 Marcus

---

## #40570 — Guilherme Blanco — 2008-09-20T10:02:29+00:00

URL: https://externals.io/message/40550#40570 · In reply to: #40568

Since these are all valid requests (I really enjoyed the euro sign
one), I'd suggest to import some ideas from Fortran and Python.

The first request is to remove the ; sign. It's annoying and everyone
here knows it. =)

My second request is is column identing.
PHP should support = assignment if defined in column 0, example:

<?php

$foo "value" // equivalent to $foo = "value"; nowadays

And since we may have to deal with other interesting situations (like
+=, -=, etc), you should put the sign before left expression

+ $foo "value" // which means $foo += "value";

The idea should be followed for:
0 equivalent to = assignment
1 equivalent to method or function call
2 function or method definition
3 normal code
4 loop
...

The idea is very simple and imagine this source that currently works:

class Foo
{
    public static function bar()
    {
        $str = '';

        for ($i = 0, $l = 10; $i < $l; $i++)
        {
            $str += '[' . $i . ']';
        }

        return $str;
    }
}

Will be simplified a lot into (and also include the euro sign suggestion):

class Foo
  static bar()
€str ''

    €i = 0, €l = 10; €i < €l; €i++
+ €str '[' . €i . ']'

   return €str


Of course this is just a RFC and we should start endless discussions
to define new terminals in grammar, but I would love to see that into
PHP 7!!!!


Cheers,


> Hello Ionut,
>
>  a Friend suggested to replace it with a Euro sign, so that PHP code gets
>  worth more :-)
>
> marcus
>
> Thursday, September 18, 2008, 8:30:37 PM, you wrote:
>
> > […]
>
> > […]
>
>
>
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
>
> > […]
>
>
> > […]
>
>
>
>
> Best regards,
>  Marcus
>
>
> --
> 
> 
>
>



-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil

---

## #40571 — Jani Taskinen — 2008-09-20T13:43:52+00:00

URL: https://externals.io/message/40550#40571 · In reply to: #40568

Marcus Boerger kirjoitti:
> Hello Ionut,
> 
>   a Friend suggested to replace it with a Euro sign, so that PHP code gets
>   worth more :-)

Hey, why not make it configurable (ini option) ?! :D

--Jani



> marcus
> 
> Thursday, September 18, 2008, 8:30:37 PM, you wrote:
> 
> > […]
> 
> > […]
> 
> 
> 
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> 
> 
> Best regards,
>  Marcus

---

## #40572 — Sotiris Karavarsamis — 2008-09-20T15:35:25+00:00

URL: https://externals.io/message/40550#40572 · In reply to: #40571

On Sat, 20 Sep 2008 16:43:52 +0300, Jani Taskinen <jani.taskinen@sci.fi>
wrote:
> Marcus Boerger kirjoitti:
> > […]
> gets
> > […]
> 
> Hey, why not make it configurable (ini option) ?! :D

I really do not find it reasonable to change the dollar sign to something
else.
If we could switch the dollar sign notation in variables on and off
with a directive in php.ini, that would break backwards compatibility
between apps
not only in a single user environments but also in shared hosting envs.
Imagine having to switch into dollar sign notation for a phpbb installation
and to a notation without the dollar sign for a custom application. It's
just
crazy!

Sotiris

> 
> --Jani
> 
> 
> 
> > […]
> rfc
> > […]

---

## #40573 — Alain Williams — 2008-09-20T16:21:47+00:00

URL: https://externals.io/message/40550#40573 · In reply to: #40572

> 
> 
> On Sat, 20 Sep 2008 16:43:52 +0300, Jani Taskinen <jani.taskinen@sci.fi>
> wrote:
> > […]
> 
> I really do not find it reasonable to change the dollar sign to something
> else.
> If we could switch the dollar sign notation in variables on and off
> with a directive in php.ini, that would break backwards compatibility
> between apps
> not only in a single user environments but also in shared hosting envs.
> Imagine having to switch into dollar sign notation for a phpbb installation
> and to a notation without the dollar sign for a custom application. It's
> just
> crazy!

I doubt that that was a serious suggestion. Just a joke.

Although I do like the idea of replacing dollar with euro .... :-)

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h

---

## #40575 — Marco — 2008-09-20T16:27:23+00:00

URL: https://externals.io/message/40550#40575 · In reply to: #40572

>
> > […]
>
> I really do not find it reasonable to change the dollar sign to something
> else.
> If we could switch the dollar sign notation in variables on and off
> with a directive in php.ini, that would break backwards compatibility
> between apps
> not only in a single user environments but also in shared hosting envs.
> Imagine having to switch into dollar sign notation for a phpbb installation
> and to a notation without the dollar sign for a custom application. It's
> just
> crazy!


http://en.wikipedia.org/wiki/Sarcasm ... I hope :-D

Regards

Marco

---

## #40576 — sotiris karavarsamis — 2008-09-20T17:59:53+00:00

URL: https://externals.io/message/40550#40576 · In reply to: #40575

Marco wrote:

So don't you consider this a serious reason against stripping/changing 
the dollar sign?
Do you think that would be a good effect for PHP users if that change 
would exist
in a future version of PHP (even in PHP6!)? It's a simple change but a 
great shift!
>
>
> > […]
>
>     I really do not find it reasonable to change the dollar sign to
>     something
>     else.
>     If we could switch the dollar sign notation in variables on and off
>     with a directive in php.ini, that would break backwards compatibility
>     between apps
>     not only in a single user environments but also in shared hosting
>     envs.
>     Imagine having to switch into dollar sign notation for a phpbb
>     installation
>     and to a notation without the dollar sign for a custom
>     application. It's
>     just
>     crazy!
>
>
> http://en.wikipedia.org/wiki/Sarcasm ... I hope :-D
I'm not being sarcastic, if you mean it. :p
>
> Regards
>
> Marco

---

## #40577 — Guilherme Blanco — 2008-09-20T18:04:02+00:00

URL: https://externals.io/message/40550#40577 · In reply to: #40576

@sotiris:

explain me how will does this be handled:

$array_pop = 'foo';

$test = $array_pop($arrayFoo); // $test = foo($arrayFoo);

if you remove the $....

array_pop = 'foo';

test = array_pop(arrayFoo); // huh?!?!?!



Cheers,


> Marco wrote:
>
> So don't you consider this a serious reason against stripping/changing the
> dollar sign?
> Do you think that would be a good effect for PHP users if that change would
> exist
> in a future version of PHP (even in PHP6!)? It's a simple change but a great
> shift!
> > […]
>
> I'm not being sarcastic, if you mean it. :p
> > […]
>
> --
> 
> 
>
>



-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
Rio de Janeiro - RJ/Brazil

---

## #40579 — sotiris karavarsamis — 2008-09-20T18:21:51+00:00

URL: https://externals.io/message/40550#40579 · In reply to: #40577

Guilherme Blanco wrote:
> @sotiris:
>
> explain me how will does this be handled:
>
> $array_pop = 'foo';
>
> $test = $array_pop($arrayFoo); // $test = foo($arrayFoo);
>
> if you remove the $....
>
> array_pop = 'foo';
>
> test = array_pop(arrayFoo); // huh?!?!?!
>   
Guilherme,
I suggest keeping the $ sign in the syntax scheme of PHP; that is clear 
in my prior
responses. Why do you actually ask this? Changing the way variables are 
denoted
by stripping the dollar sign obviously breaks previous syntax 
functionality offered
by PHP (indirect function calls through variables).
> Cheers,
>
> 
>   
> > […]

---

## #40581 — Richard Quadling — 2008-09-20T21:15:09+00:00

URL: https://externals.io/message/40550#40581 · In reply to: #40579

Apropos of nothing, if you are all looking for something to reclaim,
then how about dropping # as a comment. We've got block and single
line comments already with /* */ and //.

Then # could be the namespace separator and solve all these issues
about conflicts between namespace::function and class::static.

namespace#function() is very much distinguishable to class::static()

Richard.


-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #40582 — Diego Feitosa — 2008-09-20T21:39:54+00:00

URL: https://externals.io/message/40550#40582 · In reply to: #40581

Finally something that makes sense or at least worthy of discussion!!

But not at this thread.

Cheers,

On Sat, Sep 20, 2008 at 6:15 PM, Richard Quadling
<rquadling@googlemail.com>wrote:

> Apropos of nothing, if you are all looking for something to reclaim,
> then how about dropping # as a comment. We've got block and single
> line comments already with /* */ and //.
>
> Then # could be the namespace separator and solve all these issues
> about conflicts between namespace::function and class::static.
>
> namespace#function() is very much distinguishable to class::static()
>
> Richard.
>
>
> --
> -----
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
>
> --
> 
> 
>
>


-- 
Diego
www.dnfeitosa.com
