Re: [PHP-DEV] Re: Moving to an AST-based parsing/compilation process

2012-09-06 Thread Ivan Enderlin @ Hoa


On 05/09/12 18:59, Andrew Faulds wrote:

On 05/09/12 13:48, Morgan L. Owens wrote:
I'm not a core dev, but I would like to add to the notes above that 
third parties, such as myself, who want to do things with PHP 
source other than run it through a PHP interpreter would also 
appreciate such a separation of concerns.


To date, I've been basing work, which exposes syntactic structure, on 
phc's maketea grammar (Phalanger's is more up to date, but also more 
complicated what with its provenance and the Linq and generics and 
all), but it's reverse-engineered and certainly wrong (oh, that 
reminds me...); the existing grammar is unsuitable because no-one 
wants to see _that_.


Something authoritative that _by definition_ tracks the current 
version would be more reassuring as regards accuracy and 
compatibility (and be more likely to result in something that 
deserves to be let out into the world with confidence).




To add to your point:

If we make it produce an AST, I wonder if we could possibly expose 
this through PHP, perhaps with some sort of extension. Then parsers 
and such for PHP could simply ask PHP to do the parsing for them, and 
then do analysis - no more duplicating official PHP grammar.


I'm just speculating here, but this would be pretty cool if we could 
do it.
+1. It will be very useful for static analysis, test, control flow graph 
etc.


--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] On BC and interfaces

2012-09-06 Thread Lester Caine

Stas Malyshev wrote:

Given many discussions on the list about changing stuff in PHP, I'd like
to bring everybody's attention to comment by Linus Torvalds in this
topic:https://plus.google.com/115250422803614415116/posts/hMT5kW8LKJk



It talks about Linux kernel and discussion has next to nothing to do
with PHP, but generic point about keeping the interfaces and importance
of not serving one use case I think very important for all widely used
platforms equally. I think the opinion of the author of one of the most
successful platforms in recent history may be interesting to consider.


To quote ...
Some gnome people seem to be in total denial about what their problem really is. 
They'll wildly blame everybody except themselves. This article seems to be a 
perfect example of that.


In addition to managing all of the changes being integrated into PHP I've been 
living with the 'improvements' in Linux. KDE3 became KDE4 and in my opinion 
totally unusable! OK I'm a dodo, but simply LEARNING how to cope with a new way 
of working and fighting a deliberate policy of blocking any 'classic' theme ... 
I moved over to Gnome which did at least work more like I was comfortable with, 
and they go and do the same pigging thing! But at least someone was listening 
and I'm on a 'classic' view currently. Progress needs to be productive not 
aesthetic?


How does this relate to PHP? It's exactly the same attitude here. SPL interfaces 
are something we can currently take or leave. Personally I'd just disable them 
altogether but it seems I can't? Some would like to force them on us, and 
generators are a nail now to hang making more stuff 'core' such as more 
exceptions. But personally I don't need them. All of my persistent storage is 
via the database, and fast access to that - filtering the information required - 
processing the output - purely uses the database interface. PDO gives me nothing 
there. It's still incomplete and there is little interest in 'completing' it. 
ADOdb may be a bit bloated, but a bit more attention to the extension from those 
of you who understand the fine detail and we could have a faster well 
established alternative? Currently each major project is going of designing it's 
own alternative some based on PDO, some database specific, simply because there 
is not a GOOD standard interface to work off. Even the ZendDB interface ends up 
getting it's own custom extensions on each project making maintenance a 
nightmare. I've three different zend framework based sites I've inherited and 
all three provide a 'different' database interface! They will be moved to my own 
framework simply because it's easier than trying to learn three new methods of 
working. That and I can get everything back onto Firebird which provides 
transparent background backup's.


The drive to release more often has to have a 'reason'. And getting bug and 
security fixes out promptly is the reason, not trying to placate some self 
inflated commentator who says PHP is crap because it doesn't have ... but they 
are never going to use it anyway?


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] mysqli_fetch_field() mysqlnd libmysql differences

2012-09-06 Thread Johannes Schlüter
Hi,

On Sep 6, 2012, at 1:24, Daniel Convissor dani...@analysisandsolutions.com 
wrote:

 Hi Johannes:
 
 On Thu, Jan 19, 2012 at 01:50:47PM +0100, Johannes Schlüter wrote:
 
unsigned long length
 
The width of the field. This corresponds to the display length,
in bytes.
 
The server determines the length value before it generates the
result set, so this is the minimum length required for a data
type capable of holding the largest possible value from the
result column, without knowing in advance the actual values that
will be produced by the query for the result set.
 
http://dev.mysql.com/doc/refman/5.5/en/c-api-data-structures.html
 
 Pardon me for looping back around to this old discussion.  I had a
 moment to look at this in PEAR::DB the other day.  A new perspective
 came to mind...
 
 It seems the field length in the C API is there to aid C programmers
 with memory allocation.
 
 The field length in PHP is there for PHP programmers to reverse engineer
 database structures.
 
 These are different purposes and the output should reflect such.
 
 For example, the userland PHP field length could lead to someone dumping
 a structure that has a VARCHAR(10).  The exported metadata would say
 VARCHAR(30).  Then it gets imported and dumped again, and now we're up
 to VARCHAR(90).  Not fun.

This is all correct - but there isn't much we can do. The server provides this 
data. Trying to fix it on the client side will likely become a mess. If we 
create a mess I prefer doing it in user land (db2, mdb, doctrine, propel, ...) 
where everybody can debug/fix it.

Johannes

 Thanks for your reconsideration,
 --Dan
 
 -- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Ivan Enderlin @ Hoa

Hi Dmitry,

On 06/09/12 07:37, Dmitry Stogov wrote:

Hi Nikita,

Personally, I don't see any reason to build AST. As you mentioned 
yourself, it will be slower and will require more memory. On the other 
hand AST itself would allow to perform only very basic optimizations. 
Most of them can be easily done on VM opcode level as well.
The lexing and parsing processes will not be slower than actual, and the 
construction of an AST is a new process. Well, as usual, new process 
requires new resources. But if we look further, it will certainly be a 
nice tool to perform better opcode caching, it will remove a lot of 
hacks, it will allow third-part tools working on safeness, security, 
quality etc. to go deeper at low-costs which is very important for PHP 
community, it will facilitate future works (implementations, features 
etc.) for PHP… Moreover, it may be possible that compiler compilers have 
a better lexing and parsing processes than actual?


Someone said that AST is more “academical”, yes it is and that is why we 
can benefit from already done researches in this area to avoid memory 
overhead (one among others). We are not the first ones facing this 
problem. It requires some researches before starting to develop this. 
Let's try as a POC and we will quickly see if this is a wrong way or not.


Cheers.




Also, as it's not an easy task, the old ugly hacks will be replaced 
with new mistakes, which would require new hacks in the future :)


The only real advantage could be an ability to expose AST to PHP 
scripts, but only few people may need it.


Thanks. Dmitry.

On 09/04/2012 11:57 PM, Nikita Popov wrote:

Hey folks!

Some people asked me what the advantages of using an AST-based
parsing/compilation process are, so I put together a few quick notes
in an RFC:

https://wiki.php.net/rfc/ast_based_parsing_compilation_process

It would be nice to get a few comments from other core devs on this.

Nikita






--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Leigh
Hi

 The lexing and parsing processes will not be slower than actual, and the
construction of an AST is a new process. Well, as usual, new process
requires new resources. But if we look further, it will certainly be a nice
tool to perform better opcode caching, it will remove a lot of hacks, it
will allow third-part tools working on safeness, security, quality etc. to
go deeper at low-costs which is very important for PHP community, it will
facilitate future works

I think this is a good point to focus on, there has been a lot of comments
about the increased resource cost of the parse. What is being forgotten is
that you can offset this against all of the gains you will see as a result.

Maybe the upfront cost of a parse goes up, but once it is parsed and the
opcodes are cached, you won't have this cost again until you change the
script. Then you have all of the benefits for every subsequent request.

Increased cost once, benefits every time.
On Sep 6, 2012 8:53 AM, Ivan Enderlin @ Hoa ivan.ender...@hoa-project.net
wrote:

 Hi Dmitry,

 On 06/09/12 07:37, Dmitry Stogov wrote:

 Hi Nikita,

 Personally, I don't see any reason to build AST. As you mentioned
 yourself, it will be slower and will require more memory. On the other hand
 AST itself would allow to perform only very basic optimizations. Most of
 them can be easily done on VM opcode level as well.

 The lexing and parsing processes will not be slower than actual, and the
 construction of an AST is a new process. Well, as usual, new process
 requires new resources. But if we look further, it will certainly be a nice
 tool to perform better opcode caching, it will remove a lot of hacks, it
 will allow third-part tools working on safeness, security, quality etc. to
 go deeper at low-costs which is very important for PHP community, it will
 facilitate future works (implementations, features etc.) for PHP… Moreover,
 it may be possible that compiler compilers have a better lexing and parsing
 processes than actual?

 Someone said that AST is more “academical”, yes it is and that is why we
 can benefit from already done researches in this area to avoid memory
 overhead (one among others). We are not the first ones facing this problem.
 It requires some researches before starting to develop this. Let's try as a
 POC and we will quickly see if this is a wrong way or not.

 Cheers.



 Also, as it's not an easy task, the old ugly hacks will be replaced
 with new mistakes, which would require new hacks in the future :)

 The only real advantage could be an ability to expose AST to PHP scripts,
 but only few people may need it.

 Thanks. Dmitry.

 On 09/04/2012 11:57 PM, Nikita Popov wrote:

 Hey folks!

 Some people asked me what the advantages of using an AST-based
 parsing/compilation process are, so I put together a few quick notes
 in an RFC:

 https://wiki.php.net/rfc/ast_**based_parsing_compilation_**processhttps://wiki.php.net/rfc/ast_based_parsing_compilation_process

 It would be nice to get a few comments from other core devs on this.

 Nikita




 --
 Ivan Enderlin
 Developer of Hoa
 http://hoa.42/ or http://hoa-project.net/

 PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
 http://disc.univ-fcomte.fr/ and http://www.inria.fr/

 Member of HTML and WebApps Working Group of W3C
 http://w3.org/



 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Stas Malyshev
Hi!

 The lexing and parsing processes will not be slower than actual, and the
 construction of an AST is a new process. Well, as usual, new process
 requires new resources. But if we look further, it will certainly be a nice
 tool to perform better opcode caching, it will remove a lot of hacks, it
 will allow third-part tools working on safeness, security, quality etc. to
 go deeper at low-costs which is very important for PHP community, it will
 facilitate future works

I don't see how it would lead to better opcode caching. As for
third-party tools, I do not see why third-party tools need PHP to change
the parser. If PHP's parser is not good enough for those tools, they can
have their own parser.

 Maybe the upfront cost of a parse goes up, but once it is parsed and the
 opcodes are cached, you won't have this cost again until you change the
 script. Then you have all of the benefits for every subsequent request.

So far we have not seen not only any of these benefits, but any
explanation of what exactly these benefits would be and any proof they
would actually benefit anybody. I seriously would propose people
interested in this project just take up this project and see if it's
beneficial or not. Just talking about what might happen on the list
would achieve nothing.

 Increased cost once, benefits every time.

For now it looks like quite the reverse - increased performance and
stability costs for everybody, dubious benefits for a small group.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Ivan Enderlin @ Hoa

On 06/09/12 10:11, Stas Malyshev wrote:

Hi!


The lexing and parsing processes will not be slower than actual, and the

construction of an AST is a new process. Well, as usual, new process
requires new resources. But if we look further, it will certainly be a nice
tool to perform better opcode caching, it will remove a lot of hacks, it
will allow third-part tools working on safeness, security, quality etc. to
go deeper at low-costs which is very important for PHP community, it will
facilitate future works

I don't see how it would lead to better opcode caching.
JIT, lazy-parsing, lazy-opcode generation, caching heuristics, 
optimisation of opcode generation…
PHP is interpreted and this is why it is able to offer high dynamic 
constructions and executions. PHP incredibly scales. But we can do 
better, maybe by mixing cache + interpretation in a better way. I don't 
know. I said we are certainly not the first ones facing this “problem”. 
We have to search in the literature if such solutions exist.



As for
third-party tools, I do not see why third-party tools need PHP to change
the parser. If PHP's parser is not good enough for those tools, they can
have their own parser.
Not if we expose the AST directly into the PHP user-land (maybe through 
a specific configuration: --enable-user-ast or something like that).



Maybe the upfront cost of a parse goes up, but once it is parsed and the
opcodes are cached, you won't have this cost again until you change the
script. Then you have all of the benefits for every subsequent request.

So far we have not seen not only any of these benefits, but any
explanation of what exactly these benefits would be and any proof they
would actually benefit anybody.

Because it is a very hard topic and so, it is hard to explain quickly.


I seriously would propose people
interested in this project just take up this project and see if it's
beneficial or not. Just talking about what might happen on the list
would achieve nothing.
Exactly what I have proposed: “Let's try as a POC and we will quickly 
see if this is a wrong way or not”.


Cheers.

--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Sebastian Bergmann

On 09/06/2012 06:37 AM, Dmitry Stogov wrote:

The only real advantage could be an ability to expose AST to PHP scripts,
but only few people may need it.


 Everyone working on static analysis tools for PHP code needs access to
 the (canonical) AST. While the number of people behind this everyone
 will be small (hopefully it will grow) but the tools they create based
 based on the AST will be valuable for every PHP developer.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Moving to an AST-based parsing/compilation process

2012-09-06 Thread Morgan L. Owens

On 2012-09-06 10:39, Stas Malyshev wrote:

Hi!

... and no real
benefit for average PHP user.

Well, apart from perhaps leaving them with a simpler language that 
doesn't have the inconsistencies and corner cases that currently exist 
(and documented ad nauseum) not because of any design decision but 
because the parser is written that way.



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Sebastian Bergmann

On 09/06/2012 09:11 AM, Stas Malyshev wrote:

As for third-party tools, I do not see why third-party tools need PHP
to change the parser. If PHP's parser is not good enough for those tools,
they can have their own parser.


 Nikita is doing an amazing job with PHP_Parser, which is such a
 third-party tool. However, it will always lag behind the canonical
 parser. And it will (probably) never match 100% the behavior of the
 canonical parser.

 This is why, from my perspective of someone who is interested in static
 analysis and quality assurance, I think that it would be a tremendous
 boost for the PHP platform if we had a state-of-the-art parser for the
 reference implementation of our programming language.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Stas Malyshev
Hi!

   Nikita is doing an amazing job with PHP_Parser, which is such a
   third-party tool. However, it will always lag behind the canonical
   parser. And it will (probably) never match 100% the behavior of the
   canonical parser.

Wait, so the arguments that it will be amazingly easy to implement new
features in this parser - which should solve the problem of the lag - by
the time the old and clunky parser is released certainly it is possible
to do the same with new, much less complex and much easier to work with
parser? - so these arguments weren't true? Or am I missing some
important reason why parser that is much less complex and easier to add
things to can't do the same old one can do?

And if it's impossible to match behavior of the existing parser - do I
get it right that the proposed idea is to actually break real code that
people run now in PHP  because it was too hard to parse for people that
write add-on tools to PHP? Somehow it does not sound like a good idea.
If we have doubt that we can match the existing PHP behavior then the
idea of changing parser becomes even less appealing, because for 99% of
PHP users it would be pure downside without upsides. The users don't
care if the parser is complex, they care if their code runs.

   This is why, from my perspective of someone who is interested in static
   analysis and quality assurance, I think that it would be a tremendous
   boost for the PHP platform if we had a state-of-the-art parser for the
   reference implementation of our programming language.

I think that the benefit of it for regular PHP user is unclear (and
would not be clear until the real benefit of such parser - such as
promised optimizations, etc. - is demonstrated) but the harm from
breaking of the existing code is obvious. What would happen is that
people would just avoid running such PHP version - and what use then
would be to have excellent tools for PHP that people don't use because
it can't run their code?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Florian Anderiasch
On 09/06/2012 10:47 AM, Sebastian Bergmann wrote:
 On 09/06/2012 06:37 AM, Dmitry Stogov wrote:
 The only real advantage could be an ability to expose AST to PHP scripts,
 but only few people may need it.
 
  Everyone working on static analysis tools for PHP code needs access to
  the (canonical) AST. While the number of people behind this everyone
  will be small (hopefully it will grow) but the tools they create based
  based on the AST will be valuable for every PHP developer.
 

I fully agree with Sebastian here, nearly all the methods used in the
past to get some meaningful analysis done relied on third party tools,
were immensely prone to breakage or both.

I've used phc up to 5.2 without problems but after that I didn't really
keep up trying yet again another completely different method. This is
such a basic task for static analysis, something not in the core will
always be a second-class citizen.

And yes, the people directly benefitting from this and not indirectly
from the tools produced will probably be quite happy.

So unless something is getting slower, +1.

Greetings,
Florian

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Ferenc Kovacs
On Thu, Sep 6, 2012 at 11:10 AM, Stas Malyshev smalys...@sugarcrm.comwrote:

 Hi!

Nikita is doing an amazing job with PHP_Parser, which is such a
third-party tool. However, it will always lag behind the canonical
parser. And it will (probably) never match 100% the behavior of the
canonical parser.

 Wait, so the arguments that it will be amazingly easy to implement new
 features in this parser - which should solve the problem of the lag - by
 the time the old and clunky parser is released certainly it is possible
 to do the same with new, much less complex and much easier to work with
 parser? - so these arguments weren't true? Or am I missing some
 important reason why parser that is much less complex and easier to add
 things to can't do the same old one can do?

 And if it's impossible to match behavior of the existing parser - do I
 get it right that the proposed idea is to actually break real code that
 people run now in PHP  because it was too hard to parse for people that
 write add-on tools to PHP? Somehow it does not sound like a good idea.
 If we have doubt that we can match the existing PHP behavior then the
 idea of changing parser becomes even less appealing, because for 99% of
 PHP users it would be pure downside without upsides. The users don't
 care if the parser is complex, they care if their code runs.

This is why, from my perspective of someone who is interested in static
analysis and quality assurance, I think that it would be a tremendous
boost for the PHP platform if we had a state-of-the-art parser for the
reference implementation of our programming language.

 I think that the benefit of it for regular PHP user is unclear (and
 would not be clear until the real benefit of such parser - such as
 promised optimizations, etc. - is demonstrated) but the harm from
 breaking of the existing code is obvious. What would happen is that
 people would just avoid running such PHP version - and what use then
 would be to have excellent tools for PHP that people don't use because
 it can't run their code?
 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php


I propose putting together and RFC and a PoC ASAP, and then we can talk
about facts instead of opinions and biased views on the topic.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


Re: [PHP-DEV] Re: Moving to an AST-based parsing/compilation process

2012-09-06 Thread Stas Malyshev
Hi!

 Well, apart from perhaps leaving them with a simpler language that 
 doesn't have the inconsistencies and corner cases that currently exist 
 (and documented ad nauseum) not because of any design decision but 
 because the parser is written that way.

If you think writing new parser gets rid of all corner cases you are in
for a big surprise. AST is not magic and parser will always be written
exactly the way it is written - so if somebody won't implement certain
feature in a consistent way, it won't be implemented in consistent way,
AST or not.
And it's a bit late to take design decisions on existing PHP language,
it seems to me.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Moving to an AST-based parsing/compilation process

2012-09-06 Thread Andrew Faulds


Stas Malyshev smalys...@sugarcrm.com wrote:

Hi!

 Well, apart from perhaps leaving them with a simpler language that 
 doesn't have the inconsistencies and corner cases that currently
exist 
 (and documented ad nauseum) not because of any design decision but 
 because the parser is written that way.

If you think writing new parser gets rid of all corner cases you are in
for a big surprise. AST is not magic and parser will always be written
exactly the way it is written - so if somebody won't implement certain
feature in a consistent way, it won't be implemented in consistent way,
AST or not.
An AST allows much deeper analysis of the syntax used after parsing (i.e. 
parsing of tokens to AST), though. This means you can be greatly more flexible 
with regards to a lot of things, and greatly reduce magic corner cases, such as 
executing a closure from a dereferenced array which is a static member of a 
class (something there is no good reason you can't do, just limitations of 
current parser)
And it's a bit late to take design decisions on existing PHP language,
it seems to me.
What?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Sent from my Android phone with K-9 Mail.
Andrew Faulds
http://ajf.me/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Moving to an AST-based parsing/compilation process

2012-09-06 Thread Anthony Ferrara
Stas,

On Thu, Sep 6, 2012 at 5:25 AM, Stas Malyshev smalys...@sugarcrm.comwrote:

 Hi!

  Well, apart from perhaps leaving them with a simpler language that
  doesn't have the inconsistencies and corner cases that currently exist
  (and documented ad nauseum) not because of any design decision but
  because the parser is written that way.

 If you think writing new parser gets rid of all corner cases you are in
 for a big surprise. AST is not magic and parser will always be written
 exactly the way it is written - so if somebody won't implement certain
 feature in a consistent way, it won't be implemented in consistent way,
 AST or not.


Actually, that's not true. Right now, the parser is parsing both syntax and
a good bit of grammar. That's why we have so many reserved words. The
compiler step implements some of the grammar, but the parser takes care of
a significant amount of it.

With a move to an AST based parsing, the parser can be greatly simplified,
with a very significant reduction in reserved words. This has a few
benefits:

1. Reduced number of first-class tokens makes parsing the syntax
potentially much more efficient. This is at the expense of a more
complicated compiling step (building and processing the AST).

2. It also removes the need for the parser to worry about precedence. It's
parsing for syntax only, and then lets the AST compiler step worry about
operator precedence...

3. It provides the ability for the grammar to be extended without modifying
the syntax. That means that PECL extensions could theoretically add
compiler steps to not only extend functionality, but grammar as well. For
example, it may be possible to add language rules (such as an inline
keyword for functions, or pre-processor macros) that allow for extension of
the language without modifying the parser (I say may, because it depends
strongly on the design of the parser and AST).

4. Since the parser doesn't directly make opcodes, it would mean that
syntax errors (parse errors) would be able to be 100% recoverable. Compiler
errors would be just as difficult to recover from though.

5. It opens the door to leveraging 3pd systems. For example, the Zend VM
could hypothetically be replaced by a LLVM based VM. That would allow for
JIT based php code. Note that this isn't HipHop (which is a limited subset
of PHP), but full PHP running on a JIT VM. This could be implemented as a
PECL extension, utilizing the core parser and runtime environment, just
swapping out the executor step... Obviously this would not be trivial to
build, but right now if you wanted to build it you'd need to fork PHP to do
it (hence why the existing compilers for PHP all use a different parser).

And it's a bit late to take design decisions on existing PHP language,
 it seems to me.


It will never be easier to do than today. As time goes on, the language
will continue to grow, and the syntax and grammar will only get more
complicated from here out. So the easiest time to do it will be now...

Anthony


[PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Rasmus Schultz
I opened this bug report 2 years ago:

https://bugs.php.net/bug.php?id=52756

Is GD still actively maintained?

If it isn't, then perhaps it's time to start thinking about switching to a
graphics library that is maintained?

Perhaps something more modern with real drawing capabilities and a better
typographic engine?

Just wondering...


Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Andrew Faulds
I briefly asked Pierre about a feature in it recently. By the sounds of it, it 
is being actively maintained, albeit perhaps slowly.
-- 
Sent from my Android phone with K-9 Mail.
Andrew Faulds
http://ajf.me/

Rasmus Schultz ras...@mindplay.dk wrote:

I opened this bug report 2 years ago:

https://bugs.php.net/bug.php?id=52756

Is GD still actively maintained?

If it isn't, then perhaps it's time to start thinking about switching to a
graphics library that is maintained?

Perhaps something more modern with real drawing capabilities and a better
typographic engine?

Just wondering...



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Sebastian Bergmann

On 09/06/2012 10:15 AM, Ferenc Kovacs wrote:

I propose putting together and RFC and a PoC ASAP, and then we can talk
about facts instead of opinions and biased views on the topic.


 That would be the reasonable thing to do, yes. But that is easy for me
 easy to say as I will not be able to help in the process apart from
 testing. It is up to Nikita (and those who want to help him) to decide
 whether they want to invest their time and effort into writing a new
 parser for PHP when it is unclear whether it will be accepted.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Alexey Shein
Hi, Rasmus,

Just wanted to note that I've tested your script from
http://fontjazz.com/metrics/test.php and couldn't reproduce the bug.
I'm on the Ubuntu 12.04 with PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch

Have you tried upgrading your FreeType library and recompiling latest
stable PHP with it?

Good luck.

P.S. I'm not a GD developer.

2012/9/6 Rasmus Schultz ras...@mindplay.dk:
 I opened this bug report 2 years ago:

 https://bugs.php.net/bug.php?id=52756

 Is GD still actively maintained?

 If it isn't, then perhaps it's time to start thinking about switching to a
 graphics library that is maintained?

 Perhaps something more modern with real drawing capabilities and a better
 typographic engine?

 Just wondering...



-- 
Regards,
Shein Alexey

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Jannik Zschiesche
Am Donnerstag, 6. September 2012 um 15:05 schrieb Alexey Shein:
 Hi, Rasmus,
 
 Just wanted to note that I've tested your script from
 http://fontjazz.com/metrics/test.php and couldn't reproduce the bug.
 I'm on the Ubuntu 12.04 with PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch
 
 Have you tried upgrading your FreeType library and recompiling latest
 stable PHP with it?
 
 Good luck.
 
 P.S. I'm not a GD developer.

Hi Alexey,

I just tested it on PHP 5.4.4 on OSX and I can confirm, that the issue is still 
present.
(used font: Open Sans Regular/Bold/Italic, screenshots: http://min.us/mM2c5yyBU 
)


Cheers
Jannik Zschiesche


Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Alexey Shein
2012/9/6 Jannik Zschiesche he...@apfelbox.net:
 Am Donnerstag, 6. September 2012 um 15:05 schrieb Alexey Shein:

 Hi, Rasmus,

 Just wanted to note that I've tested your script from
 http://fontjazz.com/metrics/test.php and couldn't reproduce the bug.
 I'm on the Ubuntu 12.04 with PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch

 Have you tried upgrading your FreeType library and recompiling latest
 stable PHP with it?

 Good luck.

 P.S. I'm not a GD developer.


 Hi Alexey,

 I just tested it on PHP 5.4.4 on OSX and I can confirm, that the issue is
 still present.
 (used font: Open Sans Regular/Bold/Italic, screenshots:
 http://min.us/mM2c5yyBU )


Here is mine with georgiai.ttf
http://minus.com/mbcHodY8D8

-- 
Regards,
Shein Alexey

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Tom Boutell
The good news is that gd is pretty moribund, there isn't a lot to
maintain. But things do come up.

libgd.org has been displaying the same oops crap something happened
notice for... three years? At least? If there is no momentum to fix
that, as the original developer of gd I would be willing to restore
the classic gd documentation there and continue linking to the
bitbucket project.

On Thu, Sep 6, 2012 at 9:15 AM, Jannik Zschiesche he...@apfelbox.net wrote:
 Am Donnerstag, 6. September 2012 um 15:05 schrieb Alexey Shein:
 Hi, Rasmus,

 Just wanted to note that I've tested your script from
 http://fontjazz.com/metrics/test.php and couldn't reproduce the bug.
 I'm on the Ubuntu 12.04 with PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch

 Have you tried upgrading your FreeType library and recompiling latest
 stable PHP with it?

 Good luck.

 P.S. I'm not a GD developer.

 Hi Alexey,

 I just tested it on PHP 5.4.4 on OSX and I can confirm, that the issue is 
 still present.
 (used font: Open Sans Regular/Bold/Italic, screenshots: 
 http://min.us/mM2c5yyBU )


 Cheers
 Jannik Zschiesche



-- 
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Ferenc Kovacs
On Thu, Sep 6, 2012 at 2:53 PM, Sebastian Bergmann sebast...@php.netwrote:

 On 09/06/2012 10:15 AM, Ferenc Kovacs wrote:

 I propose putting together and RFC and a PoC ASAP, and then we can talk
 about facts instead of opinions and biased views on the topic.


  That would be the reasonable thing to do, yes. But that is easy for me
  easy to say as I will not be able to help in the process apart from
  testing. It is up to Nikita (and those who want to help him) to decide
  whether they want to invest their time and effort into writing a new
  parser for PHP when it is unclear whether it will be accepted.




what I meant to say is that currently we are arguing on feelings and
beliefs, and I can't see how could we get an agreement whether or not does
the pros overweight the cons.
that can only happen after we have something on our hands to actually pick
apart and measure.
until then there is no point making assumptions and trying to convince the
other side to change their opinions.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


Re: [PHP-DEV] On BC and interfaces

2012-09-06 Thread Levi Morrison
On Tue, Sep 4, 2012 at 1:15 AM, Stas Malyshev smalys...@sugarcrm.com wrote:

 Hi!

 Given many discussions on the list about changing stuff in PHP, I'd like
 to bring everybody's attention to comment by Linus Torvalds in this
 topic: https://plus.google.com/115250422803614415116/posts/hMT5kW8LKJk

 It talks about Linux kernel and discussion has next to nothing to do
 with PHP, but generic point about keeping the interfaces and importance
 of not serving one use case I think very important for all widely used
 platforms equally. I think the opinion of the author of one of the most
 successful platforms in recent history may be interesting to consider.
 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php


Good find, Stas.  I would like to quote a portion of it:

 One of the core kernel rules has always been that we never ever
 break any external interfaces. That rule has been there since day
 one, although it's gotten much more explicit only in the last few years.
 The fact that we break internal interfaces that are not visible to userland
 is totally irrelevant, and a total red herring.

Basically we shouldn't break any interfaces that are user-facing but
we are free to change things internally as much as we want as long as the
external interface is honored.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] On BC and interfaces

2012-09-06 Thread Leigh
 Basically we shouldn't break any interfaces that are user-facing but
 we are free to change things internally as much as we want as long as the
 external interface is honored.

So how do you actually go about adding a feature that requires an
interface change?

Take for example the SessionHandler class, that implements
SessionHandlerInterface.

Now lets say you want to add functionality to the class that allows a
user to override create_sid, and provide user-generated session ids.
It doesn't make sense to add it to the class and not the interface, so
what do you do?

* Add to SessionHandlerInterface and break BC?
* Create SessionHandlerInterfaceEx that extends the original, and have
the the class implement that?
* Create SessionHandlerInterfaceEx that contains only the new method,
and have the class implement both interfaces?
* Add to the class, but do not touch the interface?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Johannes Schlüter
On Thu, 2012-09-06 at 09:47 +0100, Sebastian Bergmann wrote:
 On 09/06/2012 06:37 AM, Dmitry Stogov wrote:
  The only real advantage could be an ability to expose AST to PHP scripts,
  but only few people may need it.
 
   Everyone working on static analysis tools for PHP code needs access to
   the (canonical) AST. While the number of people behind this everyone
   will be small (hopefully it will grow) but the tools they create based
   based on the AST will be valuable for every PHP developer.

As soon as those tools should be version independent they need their own
parser anyhow.

Aside from that: I don't see the reason for this discussion now. People
can go and implement until this is done it's hard to argue about
performance etc. as that can hardly be predicted. If people have a need
for this they are free to go. If people don't have a need for this they
won't. (A more relevant question might be Who wants to invest time on
this, certainly can be a fun project ...)

johannes



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Dmitry Stogov

On 09/06/2012 11:52 AM, Ivan Enderlin @ Hoa wrote:

Hi Dmitry,

On 06/09/12 07:37, Dmitry Stogov wrote:

Hi Nikita,

Personally, I don't see any reason to build AST. As you mentioned
yourself, it will be slower and will require more memory. On the other
hand AST itself would allow to perform only very basic optimizations.
Most of them can be easily done on VM opcode level as well.

The lexing and parsing processes will not be slower than actual, and the
construction of an AST is a new process. Well, as usual, new process
requires new resources. But if we look further, it will certainly be a
nice tool to perform better opcode caching, it will remove a lot of
hacks, it will allow third-part tools working on safeness, security,
quality etc. to go deeper at low-costs which is very important for PHP
community, it will facilitate future works (implementations, features
etc.) for PHP… Moreover, it may be possible that compiler compilers have
a better lexing and parsing processes than actual?


Few years ago we replaced flex with re2c, and got some speedup because 
re2c generated scanner used mmap() and didn't check for end of buffer, 
but after a while we realized that in case the script size is 
multiplication of PAGE_SIZE the scanner just crashes, so we had to add 
hacks to workaround :)



Someone said that AST is more “academical”, yes it is and that is why we
can benefit from already done researches in this area to avoid memory
overhead (one among others). We are not the first ones facing this
problem. It requires some researches before starting to develop this.
Let's try as a POC and we will quickly see if this is a wrong way or not.


Of course you can try it and in case it's better, faster and/or more 
clear it may be accepted. Currently, PHP allows overriding of 
zend_compile routine, so as a first step you even may implement it as 
a PHP extension without ZE modification.


Thanks. Dmitry.


Cheers.




Also, as it's not an easy task, the old ugly hacks will be replaced
with new mistakes, which would require new hacks in the future :)

The only real advantage could be an ability to expose AST to PHP
scripts, but only few people may need it.

Thanks. Dmitry.

On 09/04/2012 11:57 PM, Nikita Popov wrote:

Hey folks!

Some people asked me what the advantages of using an AST-based
parsing/compilation process are, so I put together a few quick notes
in an RFC:

https://wiki.php.net/rfc/ast_based_parsing_compilation_process

It would be nice to get a few comments from other core devs on this.

Nikita









--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Pierre Joye
hi Rasmus,

On Thu, Sep 6, 2012 at 2:07 PM, Rasmus Schultz ras...@mindplay.dk wrote:
 I opened this bug report 2 years ago:

 https://bugs.php.net/bug.php?id=52756

 Is GD still actively maintained?

yes. Slowly but yes, we will finally merge 2.1 in 5.5 too.


 Perhaps something more modern with real drawing capabilities and a better
 typographic engine?

there is gd/pango available too, it allows to replace freetype
functions transparently. Pango is much better for rendering. Not sure
if the bug you refer to is a freetype bug or something else tho'.

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Pierre Joye
On Thu, Sep 6, 2012 at 3:32 PM, Tom Boutell t...@punkave.com wrote:

 libgd.org has been displaying the same oops crap something happened
 notice for... three years? At least? If there is no momentum to fix
 that, as the original developer of gd I would be willing to restore
 the classic gd documentation there and continue linking to the
 bitbucket project.

Yes, it annoys me that the redirect stopped to work, and yes, for too
long :) The bitbucket page should show up :)

-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Moving to an AST-based parsing/compilation process

2012-09-06 Thread Nikita Popov
On Thu, Sep 6, 2012 at 11:10 AM, Stas Malyshev smalys...@sugarcrm.com wrote:
 And if it's impossible to match behavior of the existing parser - do I
 get it right that the proposed idea is to actually break real code that
 people run now in PHP  because it was too hard to parse for people that
 write add-on tools to PHP? Somehow it does not sound like a good idea.
 If we have doubt that we can match the existing PHP behavior then the
 idea of changing parser becomes even less appealing, because for 99% of
 PHP users it would be pure downside without upsides. The users don't
 care if the parser is complex, they care if their code runs.

The whole thing obviously only makes sense if we can retain full
syntax compatibility. If we have to break syntax, then this is a no-go
anyway. But I'm fairly certain that we indeed can keep full
compatibility. I implemented an AST-emitting PHP parser in PHP and am
fairly sure that it is compatible with any PHP 5.4 source code. I
don't see issues from this side.

Nikita

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] On BC and interfaces

2012-09-06 Thread Kris Craig
On Tue, Sep 4, 2012 at 12:15 AM, Stas Malyshev smalys...@sugarcrm.comwrote:

 Hi!

 Given many discussions on the list about changing stuff in PHP, I'd like
 to bring everybody's attention to comment by Linus Torvalds in this
 topic: https://plus.google.com/115250422803614415116/posts/hMT5kW8LKJk

 It talks about Linux kernel and discussion has next to nothing to do
 with PHP, but generic point about keeping the interfaces and importance
 of not serving one use case I think very important for all widely used
 platforms equally. I think the opinion of the author of one of the most
 successful platforms in recent history may be interesting to consider.
 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php


This is why I love Mr. Torvalds!  Unlike people like Jobs and Gates, Linus
stands firmly against the whole, We know what's best for you better than
you do mentality.

My newly-acquired Kindle Fire pissed me off last night.  I turned it on to
watch an episode of Futurama and read some pages from Hawking's The Grand
Design before bed, then out of nowhere it rebooted itself and began an
update process that took the better part of 30 minutes!  I was forced to
skip Futurama and just go straight to the origins of the universe.  Fucking
bastards  /rant

--Kris


Re: [PHP-DEV] On BC and interfaces

2012-09-06 Thread Will Fitch
On Thu, Sep 6, 2012 at 2:43 PM, Kris Craig kris.cr...@gmail.com wrote:

 On Tue, Sep 4, 2012 at 12:15 AM, Stas Malyshev smalys...@sugarcrm.com
 wrote:

  Hi!
 
  Given many discussions on the list about changing stuff in PHP, I'd like
  to bring everybody's attention to comment by Linus Torvalds in this
  topic: https://plus.google.com/115250422803614415116/posts/hMT5kW8LKJk
 
  It talks about Linux kernel and discussion has next to nothing to do
  with PHP, but generic point about keeping the interfaces and importance
  of not serving one use case I think very important for all widely used
  platforms equally. I think the opinion of the author of one of the most
  successful platforms in recent history may be interesting to consider.
  --
  Stanislav Malyshev, Software Architect
  SugarCRM: http://www.sugarcrm.com/
  (408)454-6900 ext. 227
 
  --
  PHP Internals - PHP Runtime Development Mailing List
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 This is why I love Mr. Torvalds!  Unlike people like Jobs and Gates, Linus
 stands firmly against the whole, We know what's best for you better than
 you do mentality.

 My newly-acquired Kindle Fire pissed me off last night.  I turned it on to
 watch an episode of Futurama and read some pages from Hawking's The Grand
 Design before bed, then out of nowhere it rebooted itself and began an
 update process that took the better part of 30 minutes!  I was forced to
 skip Futurama and just go straight to the origins of the universe.  Fucking
 bastards  /rant


You win the most random rant of the year award, Kris.



 --Kris



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Sherif Ramadan
On Thu, Sep 6, 2012 at 5:30 PM, Mark mark...@gmail.com wrote:
 Hi,

 I was just using the PHP namespaces for the first time and noticed a
 difference that i really didn't expect. (No, i won't start complaining
 about the slash based namespace).

 In C++ when you type:
 using std;

 Then you can use all methods/classes/whatever is defined in std
 without typing std.
 so: std::cout becomes just cout.

 In PHP that's a bit different. Lets take this as an example:
 =
 namespacetst.php

 ?php
 namespace Some\Long\Namespace;

 Class SomeClass
 {
 }


 Now the one using that SomeClass has to do something like this:
 index.php
 use Some\Long\Namespace;

 $oClass = new Namespace\SomeClass();
 =

 Yes, you can also do:

 index.php
 use Some\Long\Namespace\SomeClass;
 $oClass = new SomeClass();

 But i'm wondering why the use Some\Long\Namespace doesn't work like
 the C++ one. Since i would have guessed that adding that use will give
 me access to all the methods/classes/whatever that live within that
 namespace _without_ having to prefix it with the last part of the
 namespace.

 I hope someone can shed some light over this.

 Regards,
 Mark

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php



Yes, PHP namespaces are completely different from what you'd be used
to in C++. In all honesty namespaces were never well designed in PHP
and were implemented in a haphazard way, which is why I generally
don't bother using them.

To clarify, importing namespaces in PHP isn't like importing
namespaces in C++ at all, really. You are merely aliasing namespaces
in PHP when you use the use keyword. Meaning that what's actually
happening is PHP expects you to alias one namespace to another (and
thus you can never import one namespace directly into the existing
namespace since this creates a name conflict). It's messy...

NameSpacedFile.php
namespace My\Name\Space;
class MyClass { }


Index.php
use My\Name\Space; // This doesn't actually import anything
// What happened here is we created an alias
// It's the same thing as saying use My\Name\Space as \Space
// So now My\Name\Space is aliased to \Space

$obj = new \Space\MyClass; // great
$obj = new MyClass; // this won't do what you want


Here's the full example:

http://viperpad.com/qcAUNM

It simply doesn't work like that because PHP's namespaces are
implemented in such a way that they don't really resemble namespaces.
Just some fancy magic going on in the engine that allow it to mimic
namespaces.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Levi Morrison
On Thu, Sep 6, 2012 at 6:15 PM, Sherif Ramadan theanomaly...@gmail.com wrote:
 On Thu, Sep 6, 2012 at 5:30 PM, Mark mark...@gmail.com wrote:
 Hi,

 I was just using the PHP namespaces for the first time and noticed a
 difference that i really didn't expect. (No, i won't start complaining
 about the slash based namespace).

 In C++ when you type:
 using std;

 Then you can use all methods/classes/whatever is defined in std
 without typing std.
 so: std::cout becomes just cout.

 In PHP that's a bit different. Lets take this as an example:
 =
 namespacetst.php

 ?php
 namespace Some\Long\Namespace;

 Class SomeClass
 {
 }


 Now the one using that SomeClass has to do something like this:
 index.php
 use Some\Long\Namespace;

 $oClass = new Namespace\SomeClass();
 =

 Yes, you can also do:

 index.php
 use Some\Long\Namespace\SomeClass;
 $oClass = new SomeClass();

 But i'm wondering why the use Some\Long\Namespace doesn't work like
 the C++ one. Since i would have guessed that adding that use will give
 me access to all the methods/classes/whatever that live within that
 namespace _without_ having to prefix it with the last part of the
 namespace.

 I hope someone can shed some light over this.

 Regards,
 Mark

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php



 Yes, PHP namespaces are completely different from what you'd be used
 to in C++. In all honesty namespaces were never well designed in PHP
 and were implemented in a haphazard way, which is why I generally
 don't bother using them.

 To clarify, importing namespaces in PHP isn't like importing
 namespaces in C++ at all, really. You are merely aliasing namespaces
 in PHP when you use the use keyword. Meaning that what's actually
 happening is PHP expects you to alias one namespace to another (and
 thus you can never import one namespace directly into the existing
 namespace since this creates a name conflict). It's messy...

 NameSpacedFile.php
 namespace My\Name\Space;
 class MyClass { }


 Index.php
 use My\Name\Space; // This doesn't actually import anything
 // What happened here is we created an alias
 // It's the same thing as saying use My\Name\Space as \Space
 // So now My\Name\Space is aliased to \Space

 $obj = new \Space\MyClass; // great
 $obj = new MyClass; // this won't do what you want


 Here's the full example:

 http://viperpad.com/qcAUNM

 It simply doesn't work like that because PHP's namespaces are
 implemented in such a way that they don't really resemble namespaces.
 Just some fancy magic going on in the engine that allow it to mimic
 namespaces.

While that is true, I cannot stress their importance in organizing
code.  Nearly every codebase I've seen that can use namespaces maps
the namespace to the file system which makes for very easy-to-code
autoloaders.  Very helpful indeed.  It would be nice to see improved
namespaces, though.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Yahav Gindi Bar
On Fri, Sep 7, 2012 at 3:21 AM, Levi Morrison morrison.l...@gmail.comwrote:

 On Thu, Sep 6, 2012 at 6:15 PM, Sherif Ramadan theanomaly...@gmail.com
 wrote:
  On Thu, Sep 6, 2012 at 5:30 PM, Mark mark...@gmail.com wrote:
  Hi,
 
  I was just using the PHP namespaces for the first time and noticed a
  difference that i really didn't expect. (No, i won't start complaining
  about the slash based namespace).
 
  In C++ when you type:
  using std;
 
  Then you can use all methods/classes/whatever is defined in std
  without typing std.
  so: std::cout becomes just cout.
 
  In PHP that's a bit different. Lets take this as an example:
  =
  namespacetst.php
 
  ?php
  namespace Some\Long\Namespace;
 
  Class SomeClass
  {
  }
 
 
  Now the one using that SomeClass has to do something like this:
  index.php
  use Some\Long\Namespace;
 
  $oClass = new Namespace\SomeClass();
  =
 
  Yes, you can also do:
 
  index.php
  use Some\Long\Namespace\SomeClass;
  $oClass = new SomeClass();
 
  But i'm wondering why the use Some\Long\Namespace doesn't work like
  the C++ one. Since i would have guessed that adding that use will give
  me access to all the methods/classes/whatever that live within that
  namespace _without_ having to prefix it with the last part of the
  namespace.
 
  I hope someone can shed some light over this.
 
  Regards,
  Mark
 
  --
  PHP Internals - PHP Runtime Development Mailing List
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
  Yes, PHP namespaces are completely different from what you'd be used
  to in C++. In all honesty namespaces were never well designed in PHP
  and were implemented in a haphazard way, which is why I generally
  don't bother using them.
 
  To clarify, importing namespaces in PHP isn't like importing
  namespaces in C++ at all, really. You are merely aliasing namespaces
  in PHP when you use the use keyword. Meaning that what's actually
  happening is PHP expects you to alias one namespace to another (and
  thus you can never import one namespace directly into the existing
  namespace since this creates a name conflict). It's messy...
 
  NameSpacedFile.php
  namespace My\Name\Space;
  class MyClass { }
 
 
  Index.php
  use My\Name\Space; // This doesn't actually import anything
  // What happened here is we created an alias
  // It's the same thing as saying use My\Name\Space as \Space
  // So now My\Name\Space is aliased to \Space
 
  $obj = new \Space\MyClass; // great
  $obj = new MyClass; // this won't do what you want
 
 
  Here's the full example:
 
  http://viperpad.com/qcAUNM
 
  It simply doesn't work like that because PHP's namespaces are
  implemented in such a way that they don't really resemble namespaces.
  Just some fancy magic going on in the engine that allow it to mimic
  namespaces.

 While that is true, I cannot stress their importance in organizing
 code.  Nearly every codebase I've seen that can use namespaces maps
 the namespace to the file system which makes for very easy-to-code
 autoloaders.  Very helpful indeed.  It would be nice to see improved
 namespaces, though.

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php


Will the current implementation of namespace designed for import all
classes, functions and such from namespace? or it should be rewritten
entirely in order to support that?

How about adding ability to import the entire namespace?


Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Stas Malyshev
Hi!

 Yes, PHP namespaces are completely different from what you'd be used
 to in C++. In all honesty namespaces were never well designed in PHP
 and were implemented in a haphazard way, which is why I generally
 don't bother using them.

I just love how people assume if something does not fit their specific
use case people implementing it must be stupid and didn't bother to
actually think about it. If only they gave it some though, they would
definitely would do it exactly as you want.

 To clarify, importing namespaces in PHP isn't like importing
 namespaces in C++ at all, really. You are merely aliasing namespaces

There's no importing namespaces in PHP, period. It is not messy, it is
by design, and if you bothered to read extensive discussions that
happened on the list at the time, you'd know why. But of course who
needs that.

 It simply doesn't work like that because PHP's namespaces are
 implemented in such a way that they don't really resemble namespaces.

They do not resemble namespaces in C++. They resemble namespaces in PHP.
That's because PHP is not C++.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Stas Malyshev
Hi!

 How about adding ability to import the entire namespace?

This option was explicitly excluded because this defeats the whole idea
of having namespaces - i.e. having names to live in different spaces -
by explicitly bringing unknown set of names into global space. If you
allow global import, then you do not know which any of the names comes
from - it can come from any of the set of imported namespaces, or be
just global - and you have absolutely no idea about it and no way to
avoid conflicts. And all that to save you three keystrokes so you could
write DbConnection and not Db\DbConnection? Definitely not a good idea.
Current implementation makes it clear where things come from and avoids
naming conflicts, while still allowing you to use short names instead of
long and painful ones.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Sherif Ramadan
On Thu, Sep 6, 2012 at 8:37 PM, Stas Malyshev smalys...@sugarcrm.com wrote:
 Hi!

 Yes, PHP namespaces are completely different from what you'd be used
 to in C++. In all honesty namespaces were never well designed in PHP
 and were implemented in a haphazard way, which is why I generally
 don't bother using them.

 I just love how people assume if something does not fit their specific
 use case people implementing it must be stupid and didn't bother to
 actually think about it. If only they gave it some though, they would
 definitely would do it exactly as you want.

I wasn't assuming. I was outright making a factual statement. I never
made any implications of the intellectual levels of those implementing
the spec. I understand the RFC full well and know why the design is
the way it is. I was answering the ops question. Please read what I
said before you make your own assumptions.


 To clarify, importing namespaces in PHP isn't like importing
 namespaces in C++ at all, really. You are merely aliasing namespaces

 There's no importing namespaces in PHP, period. It is not messy, it is
 by design, and if you bothered to read extensive discussions that
 happened on the list at the time, you'd know why. But of course who
 needs that.

Right, that's exactly what I said. Thanks for reiterating.


 It simply doesn't work like that because PHP's namespaces are
 implemented in such a way that they don't really resemble namespaces.

 They do not resemble namespaces in C++. They resemble namespaces in PHP.
 That's because PHP is not C++.


Sure, I just said that. Albeit I said it a more indirect manner.

 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Stas Malyshev
Hi!

 In C++ when you type:
 using std;
 
 Then you can use all methods/classes/whatever is defined in std
 without typing std.
 so: std::cout becomes just cout.

PHP namespaces do not work like that. In PHP, namespace is a permanent
part of the class/function name. All namespace translations are done in
compile-time (which is not the same as compile-time in C++, btw) and are
simple alias translations.

PHP explicitly avoids mass imports, because this would lead to context
pollution and interoperability problems - i.e., if you have some
function named foo in two namespaces and you import both, you may have
problems. And since imported namespaces usually mean somebody else's
code, you may not have control or good information about changes, making
importing code fragile. Since unlike C++ PHP does not have compiler that
can resolve all the mess before it is run, PHP has to be more
conservative in order to avoid problems.
For this reason, PHP's use is nothing more than aliasing operator. It
does not put any other names into global space but the names
specifically mentioned by it. So, if you have to do std::cout, it'd
still be std\cout, but if you want to do
some\long\import\namespace\cout, you can alias
some\long\import\namespace to mystd, and do mystd\cout. So you never
have to do more than one \, but you still have to do one, to avoid
polluting global space.

 But i'm wondering why the use Some\Long\Namespace doesn't work like
 the C++ one. Since i would have guessed that adding that use will give
 me access to all the methods/classes/whatever that live within that
 namespace _without_ having to prefix it with the last part of the
 namespace.

This is exactly what we were trying to avoid - for the reasons described
above.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Yahav Gindi Bar
On Fri, Sep 7, 2012 at 3:41 AM, Stas Malyshev smalys...@sugarcrm.comwrote:

 Hi!

  How about adding ability to import the entire namespace?

 This option was explicitly excluded because this defeats the whole idea
 of having namespaces - i.e. having names to live in different spaces -
 by explicitly bringing unknown set of names into global space. If you
 allow global import, then you do not know which any of the names comes
 from - it can come from any of the set of imported namespaces, or be
 just global - and you have absolutely no idea about it and no way to
 avoid conflicts. And all that to save you three keystrokes so you could
 write DbConnection and not Db\DbConnection? Definitely not a good idea.
 Current implementation makes it clear where things come from and avoids
 naming conflicts, while still allowing you to use short names instead of
 long and painful ones.
 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227


That's true, but we do got the ability to import only one class from given
namespace and classes aliasing so we can, for example, do something like:

namespaceClasses.php

namespace MyNamespace;
class Foo { }
class Bar { }
class Baz  { }

use \MyNamespace\* {
   Foo as F
   Bar as B
};

Then - the Foo and Bar classes will be F and B while Baz and any other
class remain Baz.
I do understand the point of conflicts, but I think that we should give the
programmer the ability to decide whether to import specific class or the
entire namespace.

Other option I've thought of is to declare rules for importing as keywords
or even a function that can import the namespace with given conflict rules

for example

use \MyNamespace\* noconflict;

or even
import_namespace('\MyNamespace', NS_AVOID_CONFICT);

or something like that, though I think that a keyword allocated only to
that propose is definitely not good approach...


Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Stas Malyshev
Hi!

 That's true, but we do got the ability to import only one class from
 given namespace and classes aliasing so we can, for example, do
 something like:

When you import one name, you see this name in import statement. It's
explicit. Global imports are not.

I really hate to rehash discussion from years ago all from the start.
Please believe we did think about it - including having special options,
functions, configurations, INI entries, etc. for defining imports. It's
not worth it to save couple of keystrokes on namespace prefix, really.
Not everything should live in global space, that's the whole point of
namespaces.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Stas Malyshev
Hi!

 I wasn't assuming. I was outright making a factual statement. I never
 made any implications of the intellectual levels of those implementing
 the spec. I understand the RFC full well and know why the design is
 the way it is. I was answering the ops question. Please read what I
 said before you make your own assumptions.

Sorry, statements like haphazard way, never well designed, it's a
mess, they don't really resemble namespaces, just some fancy magic,
etc. have nothing to do with facts. Actually, facts are exactly the
opposite - they were designed, were extensively discussed with
soliciting feedback from many stakeholders, and were implemented exactly
as planned. You may not like the way there were implemented, that's your
opinion (not a fact) and you are entitled to it. But you didn't limit
yourself to saying I don't like them. You specifically said that they
were never well designed and haphazardly implemented. This is factually
false.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Sherif Ramadan
On Thu, Sep 6, 2012 at 9:00 PM, Stas Malyshev smalys...@sugarcrm.com wrote:
 Hi!

 I wasn't assuming. I was outright making a factual statement. I never
 made any implications of the intellectual levels of those implementing
 the spec. I understand the RFC full well and know why the design is
 the way it is. I was answering the ops question. Please read what I
 said before you make your own assumptions.

 Sorry, statements like haphazard way, never well designed, it's a
 mess, they don't really resemble namespaces, just some fancy magic,
 etc. have nothing to do with facts. Actually, facts are exactly the
 opposite - they were designed, were extensively discussed with
 soliciting feedback from many stakeholders, and were implemented exactly
 as planned. You may not like the way there were implemented, that's your
 opinion (not a fact) and you are entitled to it. But you didn't limit
 yourself to saying I don't like them. You specifically said that they
 were never well designed and haphazardly implemented. This is factually
 false.

Fair enough. I'll be more careful to separate my opinions from my
objective answers next time :)


 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Rasmus Schultz
Jannik,

Thank you - this confirms I'm not crazy, or at least it's evidence to
support that theory ;-)

It may be OS specific - perhaps the Windows and OSX binaries are built
against a different build (or configuration) of FreeType?

Or it could be specific to 32 or 64 bit builds.

I have never built PHP (or any other C project since 15 years ago in
school) so I really have no way to take this any further...

Thanks!


On Thu, Sep 6, 2012 at 9:15 AM, Jannik Zschiesche he...@apfelbox.netwrote:


 Hi Alexey,

 I just tested it on PHP 5.4.4 on OSX and I can confirm, that the issue is
 still present.
 (used font: Open Sans Regular/Bold/Italic, screenshots:
 http://min.us/mM2c5yyBU )


 Cheers
 Jannik Zschiesche



Re: [PHP-DEV] Why are the PHP namespaces different compared to C++?

2012-09-06 Thread Etienne Kneuss
Hi,

On Fri, Sep 7, 2012 at 2:49 AM, Yahav Gindi Bar g.b.ya...@gmail.com wrote:
 On Fri, Sep 7, 2012 at 3:41 AM, Stas Malyshev smalys...@sugarcrm.comwrote:

 Hi!

  How about adding ability to import the entire namespace?

 This option was explicitly excluded because this defeats the whole idea
 of having namespaces - i.e. having names to live in different spaces -
 by explicitly bringing unknown set of names into global space. If you
 allow global import, then you do not know which any of the names comes
 from - it can come from any of the set of imported namespaces, or be
 just global - and you have absolutely no idea about it and no way to
 avoid conflicts. And all that to save you three keystrokes so you could
 write DbConnection and not Db\DbConnection? Definitely not a good idea.
 Current implementation makes it clear where things come from and avoids
 naming conflicts, while still allowing you to use short names instead of
 long and painful ones.
 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227


 That's true, but we do got the ability to import only one class from given
 namespace and classes aliasing so we can, for example, do something like:

 namespaceClasses.php

 namespace MyNamespace;
 class Foo { }
 class Bar { }
 class Baz  { }

 use \MyNamespace\* {
Foo as F
Bar as B
 };

 Then - the Foo and Bar classes will be F and B while Baz and any other
 class remain Baz.
 I do understand the point of conflicts, but I think that we should give the
 programmer the ability to decide whether to import specific class or the
 entire namespace.

 Other option I've thought of is to declare rules for importing as keywords
 or even a function that can import the namespace with given conflict rules

 for example

 use \MyNamespace\* noconflict;

 or even
 import_namespace('\MyNamespace', NS_AVOID_CONFICT);

 or something like that, though I think that a keyword allocated only to
 that propose is definitely not good approach...

The reason why this is not implemented is simple, and it's not to
avoid hard-to-read code or by design. It is a purely technical
limitation of the way PHP handles classes/namespaces:

When importing a namespace, PHP may have no idea of the classes
contained in that namespace. So when you do

use Foo\Bar as Gee;

PHP have no idea what Foo\Bee really is, whether it is a namespace
itself or a class. Nothing might be loaded at that time. *All* it
knows is that it needs to substitute occurrences of Gee with
Foo\Bar, that's it.
Now of course, this wouldn't work with wildcard imports, because if you do:

use Foo\*;
use Bar\*;

new Plop;

Even though Plop might only be contained in one of those namespaces,
PHP does not necessarily know, and it doesn't know whether to try
\Plop, Foo\Plop, or Bar\Plop.

This problem is of course non-existent in other languages supporting
wildcard imports, because the set of imported classes is finite and
well known, which means that conflicts can be detected right away.

Best,

-- 
Etienne Kneuss

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] is GD being actively maintained?

2012-09-06 Thread Pierre Joye
On Fri, Sep 7, 2012 at 3:09 AM, Rasmus Schultz ras...@mindplay.dk wrote:
 Jannik,

 Thank you - this confirms I'm not crazy, or at least it's evidence to
 support that theory ;-)

 It may be OS specific - perhaps the Windows and OSX binaries are built
 against a different build (or configuration) of FreeType?

It can depend on three things:

- bug in gd (bbox  or offset calculation)
- freetype version
- freetype options (some options, not always enabled, strongly affects
rendering)

cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php