Re: [PHP-DEV] property de-referencing

2013-05-07 Thread Levi Morrison
> I am really surprised that there is so few people interested in such a > feature. IMO, it's an amazing idea, not just for forms, and not just for > properties. > It's not that the idea isn't useful; I just don't think I need a dedicated syntax for it. If we're going to be adding syntax I'd much

Re: [PHP-DEV] property de-referencing

2013-05-07 Thread Matthieu Napoli
I am really surprised that there is so few people interested in such a feature. IMO, it's an amazing idea, not just for forms, and not just for properties. Here is a quick list of use cases where one would use "meta" on its code: - Forms generation (examples have already been given) - ORM mapp

Re: [PHP-DEV] property de-referencing

2013-05-07 Thread Rasmus Schultz
I have tried tons of other languages, actively watching at least a few others in the hopes they'll mature - but I keep coming back to PHP for some reason. It's an abusive relationship. Maybe I should seek counseling ;-) On Tue, May 7, 2013 at 11:15 AM, Seva Lapsha wrote: > Maybe PHP is just not

Re: [PHP-DEV] property de-referencing

2013-05-07 Thread Seva Lapsha
Maybe PHP is just not for you. There are other languages in the sea :) On Tue, May 7, 2013 at 10:32 AM, Rasmus Schultz wrote: > And what do good developers do when the best ways have long since been > identified - and the limitations of the language prevents them from > implementing any new ide

Re: [PHP-DEV] property de-referencing

2013-05-07 Thread Rasmus Schultz
And what do good developers do when the best ways have long since been identified - and the limitations of the language prevents them from implementing any new ideas? I have hundreds of PHP experiments collected in a sandbox over the years - a good way to build and handle web-forms is one of the l

Re: [PHP-DEV] property de-referencing

2013-05-07 Thread Seva Lapsha
Good developers research and find *best* ways to use the available tools before inventing new ones. On Mon, May 6, 2013 at 2:46 PM, Rasmus Schultz wrote: > Well, I don't disagree as such - there's any number of (mostly bad) ways > to work around missing language features... > > > On Mon, May 6,

Re: [PHP-DEV] property de-referencing

2013-05-06 Thread Rasmus Schultz
Well, I don't disagree as such - there's any number of (mostly bad) ways to work around missing language features... On Mon, May 6, 2013 at 1:12 PM, Seva Lapsha wrote: > BTW, I didn't propose to wrap any use of a property reference into a meta > object, in this case a certain distinguishable str

Re: [PHP-DEV] property de-referencing

2013-05-06 Thread Seva Lapsha
BTW, I didn't propose to wrap any use of a property reference into a meta object, in this case a certain distinguishable string format could represent it with no extra handling. On Mon, May 6, 2013 at 12:44 PM, Rasmus Schultz wrote: > Seva, > > I understand that you can reference properties mor

Re: [PHP-DEV] property de-referencing

2013-05-06 Thread Seva Lapsha
Not elegant - true, not expressive - I don't agree. My reference to Java was not to point how things should be, but how people find *proper* ways to overcome missing edge features of a language. On Mon, May 6, 2013 at 12:44 PM, Rasmus Schultz wrote: > Seva, > > I understand that you can refere

Re: [PHP-DEV] property de-referencing

2013-05-06 Thread Rasmus Schultz
Seva, I understand that you can reference properties more consistently using "{fullClassName}::{fieldName}" notation, but it's still a string, and although it's now almost practically safe to assume that strings formatted in that way are property-references, it still doesn't address the problem in

Re: [PHP-DEV] property de-referencing

2013-05-06 Thread Seva Lapsha
Hi Rasmus, I agree with you that strings are not the best way to refer to an element sometimes. However, to me your Symfony2 example only demonstrates the flaw of the component's design decision, not the limitation of the language. Sometimes developers (not just Symfony, but other frameworks too)

Re: [PHP-DEV] property de-referencing

2013-05-03 Thread Nikita Popov
On Fri, May 3, 2013 at 1:32 PM, Rasmus Schultz wrote: > That's an interesting spin on the idea, but it takes away the ability to > lazy-evaluate an entire path - now it works only for the last property, > which may not always be optimal or desirable. > > I don't personally have a problem with put

Re: [PHP-DEV] property de-referencing

2013-05-03 Thread Rasmus Schultz
That's an interesting spin on the idea, but it takes away the ability to lazy-evaluate an entire path - now it works only for the last property, which may not always be optimal or desirable. I don't personally have a problem with putting the operator before the expression, I think that's clear eno

Re: [PHP-DEV] property de-referencing

2013-05-03 Thread Lazare Inepologlou
2013/5/2 Bernhard Schussek > 2013/5/1 Rasmus Schultz > > > > One could > > > write a PropertyReference class right now with literally the only > > > difference being the lack of a builtin operator (ie new > > > PropertyReference($obj, 'prop') versus ^$obj->prop): the fact that > > > nobody seem

Re: [PHP-DEV] property de-referencing

2013-05-02 Thread Rasmus Schultz
n addition your new feature is only syntactic sugar and can > be achieved with more or less the same amount of code. Sorry, I have to ask > again, did I miss something of your new language feature or is it really > just a shorthand for “new PropertyReference($user, 'name');”? > >

Re: [PHP-DEV] property de-referencing

2013-05-02 Thread Rasmus Schultz
Oh, here's a thought: let's just throw more annotations at it? $config = /** @ref AppConfiguration */ array( 'services' => /** @ref ServiceContainer */ array( /** @ref PDO */ array( 'username' => 'foo', 'password' => 'bar', ) ), ); This would work

Re: [PHP-DEV] property de-referencing

2013-05-02 Thread Rasmus Schultz
> > "authors[0].personalDetails[firstName]" > > >> which translates to > > >> ->getAuthors()[0]->getPersonalDetails()['firstName'] > > It's indirection via strings. This particular example isn't great for what I'm proposing, because you're not accessing a property - using an array-index, you get a

Re: [PHP-DEV] property de-referencing

2013-05-02 Thread Rasmus Schultz
oint of view. Imagine an > abstract syntax tree. They would look alike because ^$user->name; is only a > shorthand for new PropertyReference($user, 'name');**** > > ** ** > > Cheers, > > Robert > > ** ** > > ** ** > > ** ** > > *Vo

Re: [PHP-DEV] property de-referencing

2013-05-02 Thread Bernhard Schussek
2013/5/1 Rasmus Schultz > > One could > > write a PropertyReference class right now with literally the only > > difference being the lack of a builtin operator (ie new > > PropertyReference($obj, 'prop') versus ^$obj->prop): the fact that > > nobody seems to have done this in a major framework I

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Etienne Kneuss
On Thu, May 2, 2013 at 2:07 AM, Rasmus Schultz wrote: > > I believe you have difficulties explaining these benefits because you > first need to argue why you want reflected properties all over the place. > And once that is established (assuming it is), why you would need dedicated > syntax for it

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
factoring functionalities to a certain extend. > > -Ursprüngliche Nachricht- > Von: ekne...@gmail.com [mailto:ekne...@gmail.com] Im Auftrag von Etienne > Kneuss > Gesendet: Mittwoch, 1. Mai 2013 22:12 > An: Rasmus Schultz > Cc: Rasmus Lerdorf; Stas Malyshev; PHP internals > Betr

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
> I believe you have difficulties explaining these benefits because you first need to argue why you want reflected properties all over the place. And once that is established (assuming it is), why you would need dedicated syntax for it. I thought that's what I had been doing? Apparently I've just

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Etienne Kneuss
On Wed, May 1, 2013 at 7:13 PM, Rasmus Schultz wrote: > The only reason being that the syntax "^$user->name" is "more static" than >> new PropertyReference($user, 'name'), and thus easier to refactor? > > > Not "more static", it is static - a string-based property-reference is not. > > Refactori

RE: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
ference properties using strings - rather than using native variable-references as in your example. --- From: "Ford, Mike" To: PHP internals Cc: Date: Wed, 1 May 2013 13:20:32 +0000 Subject: RE: [PHP-DEV] property de-referencing I know I'm still somewhat of a beginner with O

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
> > The only reason being that the syntax "^$user->name" is "more static" than > new PropertyReference($user, 'name'), and thus easier to refactor? Not "more static", it is static - a string-based property-reference is not. Refactoring isn't the only benefit - of course most of the benefits are

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Sherif Ramadan
On May 1, 2013 8:35 AM, "Rasmus Schultz" wrote: > > > > > This is a fringe feature, as evidenced by the fact that you > > are having a hard time convincing people that it is needed > > > As with anything that isn't already established and well-known, it's hard This is like building something and

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Etienne Kneuss
On Wed, May 1, 2013 at 2:35 PM, Rasmus Schultz wrote: > > > > This is a fringe feature, as evidenced by the fact that you > > are having a hard time convincing people that it is needed > > > As with anything that isn't already established and well-known, it's hard > to convince anyone they need a

RE: [PHP-DEV] property de-referencing

2013-05-01 Thread Ford, Mike
ersity, Portland Way, LEEDS,  LS1 3HE,  United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 > -Original Message- > From: Rasmus Schultz [mailto:ras...@mindplay.dk] > Sent: 01 May 2013 13:35 > To: Rasmus Lerdorf > Cc: Stas Malyshev; PHP internals > Subject: Re: [P

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Peter Lind
On 1 May 2013 14:55, Rasmus Schultz wrote: > Then why are you not convincing them first to get them on board as support >> for your proposal. > > > It's not a proposal yet - I didn't want to write a lengthy RFC just to > learn that all I had was a brainfart, or that everyone was going to be > tot

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
> > Then why are you not convincing them first to get them on board as support > for your proposal. It's not a proposal yet - I didn't want to write a lengthy RFC just to learn that all I had was a brainfart, or that everyone was going to be totally opposed. Having the discussion here surfaced a

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Peter Lind
On 1 May 2013 14:35, Rasmus Schultz wrote: > > > > This is a fringe feature, as evidenced by the fact that you > > are having a hard time convincing people that it is needed > > > As with anything that isn't already established and well-known, it's hard > to convince anyone they need anything the

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
> > This is a fringe feature, as evidenced by the fact that you > are having a hard time convincing people that it is needed As with anything that isn't already established and well-known, it's hard to convince anyone they need anything they don't understand - I think the barrier here is me havin

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Rasmus Schultz
> > This won't work, because Task::$task is a protected property It will work for code that's properly documented with @property annotations. On Wed, May 1, 2013 at 7:05 AM, Jannik Zschiesche wrote: > Hi, > > Lazare Inepologlou > Mittwoch, 1. Mai 2013 10:55 > Hello, > > 2013/5/1 Stas Malys

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Jannik Zschiesche
Hi, Lazare Inepologlou Mittwoch, 1. Mai 2013 10:55 Hello,2013/5/1 Stas Malyshev The result is the same with "new ReplectionMethod('foo','bar')". The addedvalue is that it can be statically checked. well... yes and no. Take the Symfony2 example: you want to reference ^$

Re: [PHP-DEV] property de-referencing

2013-05-01 Thread Lazare Inepologlou
Hello, 2013/5/1 Stas Malyshev > Hi! > > > In C#, they had the intention to introduce the operator infoof(...) to > > get the reflection, not only of properties, but of virtually everything > > in the language. They abandoned the idea because it is really hard to do > > that for overloaded functi

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Lerdorf
On 04/30/2013 05:17 PM, Rasmus Schultz wrote: > If the asterisk (or some other character) offers and easier > implementation path, whatever. It doesn't. This is a fringe feature, as evidenced by the fact that you are having a hard time convincing people that it is needed, and thus shouldn't overl

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
Okay, that is a technical/implementation problem - and I'm not the guy who can answer than question. I was thinking there might be a mathematical (or other) operator that doesn't work without something in front of it to operate on, and I chose the ^ operator based on a wild guess, plus the followi

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
> > one problem I have with this example is, that you usually (or at least > often) don't have a "$task" object here. I get what you're saying, but you do have a $task object if you want to use the form-builder, because it relies on the object for state. The same is true for most frameworks, and

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
On Tue, Apr 30, 2013 at 7:34 PM, Adam Harvey wrote: > I would caution against generalising use cases. Personally, ::class is > something I can use multiple times a day. This I'm not so sure about. > > Your use case is not my use case, and vice versa. :) > What is your use-case then? DI perhaps?

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Lerdorf
On 04/30/2013 03:24 PM, Rasmus Schultz wrote: > Are we really going to quibble about syntax? This adds nothing to this > discussion. And as I explained earlier, the ^ operator is used for the sake > of discussion only - if it's more practical to use another character for > this operator, I don't ca

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Sebastian Krebs
2013/5/1 Rasmus Schultz > Any PHP dev who works with a mainstream framework does this daily, but the > frameworks rely on strings for property-names. > > Take this example from the Symfony manual, for example: > > > class Task > { > protected $task; > > pro

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
I've already demonstrated and explained what's wrong with strings. "Weird indirection" is what we have in every mainstream framework right now, where properties can be referenced only as strings - I gave a real-world example of this, and demonstrated with a practical example how the proposed featu

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Adam Harvey
On 30 April 2013 16:15, Rasmus Schultz wrote: > At the risk of starting a separate discussion, the recently added > ClassName::class constant provides a way to statically reference a class, > which frankly has very few practical applications in comparison - the need > to reference properties is us

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Stas Malyshev
Hi! > Any PHP dev who works with a mainstream framework does this daily, but > the frameworks rely on strings for property-names. What's wrong with strings? Just because it doesn't have three levels of objects on it, doesn't mean it's not OK to use it. > We now have static property-references, w

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
I suggested something similar earlier: http://marc.info/?t=13632784962&r=1&w=2 However, I withdrew that idea, because I came to the realization that, for practical applications, you usually need the object-context coupled with the member-reference to do anything really useful. A form-input a

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Stas Malyshev
Hi! > In C#, they had the intention to introduce the operator infoof(...) to > get the reflection, not only of properties, but of virtually everything > in the language. They abandoned the idea because it is really hard to do > that for overloaded functions and they did not want to do all that wor

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
Any PHP dev who works with a mainstream framework does this daily, but the frameworks rely on strings for property-names. Take this example from the Symfony manual, for example: class Task { protected $task; protected $dueDate; public functio

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Lazare Inepologlou
2013/4/30 Rasmus Lerdorf > On 04/30/2013 01:58 PM, Stas Malyshev wrote: > > Hi! > > > >> I'm proposing we need a way to statically reference an object property - > >> the object property itself, not it's value: > > > > You probably have use case for that, and it should be pretty easy to > > write

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Lerdorf
On 04/30/2013 01:58 PM, Stas Malyshev wrote: > Hi! > >> I'm proposing we need a way to statically reference an object property - >> the object property itself, not it's value: > > You probably have use case for that, and it should be pretty easy to > write a class that does that, but why it shoul

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Stas Malyshev
Hi! > I'm proposing we need a way to statically reference an object property - > the object property itself, not it's value: You probably have use case for that, and it should be pretty easy to write a class that does that, but why it should be in the language? It certainly doesn't look like some

[PHP-DEV] Re: [lists.php] Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
I don't think that's necessary - the point of being able to do this, is to apply meta-programming techniques, so in most situations, what matters is the ability to quickly create object/property-references... using them will usually happen inside some service component, e.g. a form-helper or object

[PHP-DEV] Re: [lists.php] Re: [PHP-DEV] property de-referencing

2013-04-30 Thread ALeX
Just an idea: why not also use ^ (or another operator) to access the value? (maybe as an additional way to get/setValue) $foo = ^$user->name; echo 'Hello '.^$foo; ^$foo = 'Bob'; (using the same operator will conflict when you are accessing a property of an object which is a PropertyReference) -

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
That looks more pointless than evil to me - and no, I'm not suggesting anything of that sort. I'm proposing we need a way to statically reference an object property - the object property itself, not it's value: var_dump($user->name); // => 'Rasmus' var_dump(^$user->name); // => PropertyR

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Ferenc Kovacs
2013.04.30. 14:00, "Rasmus Schultz" ezt írta: > > > > > Do you mean something yucky like http://pecl.php.net/propro? > > > > > I don't know what that is, and there is no description on that page. you can grasp the concept from the testcase: http://git.php.net/?p=pecl/php/propro.git;a=blob_plain;f

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Rasmus Schultz
> > Do you mean something yucky like http://pecl.php.net/propro? > > I don't know what that is, and there is no description on that page. > It's actually been meant to be used by extensions for internal properties, >> but it might do the evil you're looking for. > > Would you care to elaborate? W

Re: [PHP-DEV] property de-referencing

2013-04-30 Thread Michael Wallner
On 30 April 2013 01:45, Rasmus Schultz wrote: > The characters was an arbitrary choice, just for the sake of argument. > > I'm not a C programmer, so I don't have a patch - there is also no RFC, but > there is general interest, I'd be happy to write one. > > On Mon, Apr 29, 2013 at 5:22 AM, Lars

Re: [PHP-DEV] property de-referencing

2013-04-29 Thread Rasmus Schultz
The characters was an arbitrary choice, just for the sake of argument. I'm not a C programmer, so I don't have a patch - there is also no RFC, but there is general interest, I'd be happy to write one. On Mon, Apr 29, 2013 at 5:22 AM, Lars Strojny wrote: > Hi Rasmus, > > Am 25.04.2013 um 14:47 s

Re: [PHP-DEV] property de-referencing

2013-04-29 Thread Lars Strojny
Hi Rasmus, Am 25.04.2013 um 14:47 schrieb Rasmus Schultz : [...] > > What do you think? I'm not sure about the operator character but the general idea is a good one. Do you have a patch as a POC? cu, Lars -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://ww

Re: [PHP-DEV] property de-referencing

2013-04-25 Thread Rasmus Schultz
> > Maybe I didn't understand what you mean, but if you want property > references, why not just use, well, property references? Property-references don't know what property they're referencing - they reference the object/value held by the property, not the property itself. If you want more than

Re: [PHP-DEV] property de-referencing

2013-04-25 Thread Nikita Popov
On Thu, Apr 25, 2013 at 2:47 PM, Rasmus Schultz wrote: > Okay, > > No one seemed extremely interested in my notes about static > type-references- I want > to bring up something closely related that could possibly be even > more useful, in particular fo