Re: [PHP-DEV] File system watcher/monitoring

2013-02-15 Thread Victor Berchet


On 02/14/2013 03:03 PM, Ivan Enderlin @ Hoa wrote:

Hi internal,

A missing feature in PHP is a file system watcher/monitoring available 
for almost all platforms. On Linux, we have inotify (available in PHP 
through pecl/inotify), on Mac OS X, we have /dev/fsevents (not 
available in PHP, since we need ioctl to do that in pure PHP —and 
sudo—, no C extension needed), on FreeBSD, we have FAM, and on 
Windows, we have FileSystemWatcher in .NET. All major platforms have a 
solution ready to use.


By now, if we didn't use these solutions, we should use a finder 
(thanks to RecursiveIteratorIterator and DirectoryIterator in SPL) 
that runs every n seconds and compute a diff with the previous run. 
This solution works fine for a small set of files but it can slow for 
a big one. This is just a tricky solution, not a proper one.


Possible domains where it is needed: test, CI, log, file transfering, 
security etc.


Is it possible to have such a feature landing in PHP (core if karma 
allows it)? or do you want such a feature?


Best regards :-).


Ivan,

Everzet has started to build a client side solution[1]

Hopefuly he will have time to update the PR with what is remaining to do 
soon[2]


[1] https://github.com/symfony/symfony/pull/4605
[2] https://twitter.com/everzet/status/302381248620408832

Cheers,
Victor

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



Re: [PHP-DEV] [RFC] Integrating Zend Optimizer+ into the PHP distribution

2013-01-29 Thread Victor Berchet


On 01/29/2013 10:47 AM, Martin Keckeis wrote:

 From the perspective of the end-user this would be really great!
If it could really be done in 2 months - wait for it.


Why should we break the PHP release process by 2 months+ to include O+ ?
There are alternatives (APC to name one) and O+ might also be used on 
top of the core (I don't know it to be able to tell).


I think waiting 10 months (12-2) is preferrable and O+ would go in the 
next PHP release (if accepted).
There is really no point in delaying a relase for a feature (vs a bug 
fix) - even more when substitutes exist.


My 2 cents,
Victor

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



Re: [PHP-DEV] How about implementing more data structures (ie Map, Set)

2012-12-21 Thread Victor Berchet

I don't have much time to work on this now.

More next year !

Have ahappy Xmas.

On 12/20/2012 09:43 PM, Levi Morrison wrote:

As mentioned earlier, I've been working on a
library(https://github.com/morrisonlevi/Ardent) with an honest effort
to make the data-structures usable in several different programming
styles.  I've tried several designs, but requiring something to
implement a `Comparable` interface turned out to not be a very good
way to do things, for several reasons I don't feel like going into at
the moment.

-

I hope you'll take a look at the current
Map(https://github.com/morrisonlevi/Ardent/blob/master/src/Ardent/Map.php)
and Set(https://github.com/morrisonlevi/Ardent/blob/master/src/Ardent/Set.php)
interfaces in my library and see if there is anything you are missing.
  I'd really love it if you cloned the repository and tried using it in
your project. I'm always looking for  feedback.





[PHP-DEV] How about implementing more data structures (ie Map, Set)

2012-12-18 Thread Victor Berchet

Dear all:

I would like to get your feedback on implementing some more data 
structure in the PHP core.


Things like Set, Map could be really helpful.

A Set would be an unordered collection with no duplicate elements (same 
as in Python)


$setA = new Set();
$setA-append('a');
$setA-append('a');

$setB = new Set();
$setB-append('b');

$setA == $setB;

// A set can hold objects
$set-append($object);

A Map would be an associative array that can hold objects (same as 
Python dictionaries)


$map= new Map();

$map[$setA] = 'Hello, world!';
echo $maps[$setB]; // Hello, world !

I can not really help with the implementation, however I could help 
defining the API, creating a test suite and docs should this idea be 
accepted.


Note: I had to implement this in PHP while working on Automaton, it's 
tedious and inefficient.


Thanks for your feedback,
Victor





Re: [PHP-DEV] How about implementing more data structures (ie Map, Set)

2012-12-18 Thread Victor Berchet
I am happy to see some interest in this discussion, I'll try to give 
more details in the coming days.


To clarify, my first example should be:

$setA = new Set();
$setA-append('a');
$setA-append('a');

$setB = new Set();
$setB-append('a'); // 'a' instead of 'b'

$setA == $setB;

Cheers,
Victor

On 12/18/2012 07:32 PM, Anthony Ferrara wrote:

Guys,

PHP arrays are a great one-size-fits-all data structure. But like all 
one-size-fits-all anything, jack-of-all-trades usually means master 
of none.


There are definitely benefits to using specific data structures if 
implemented correctly under the hood.


A good example of this is a Queue. Implemented properly using a 
Singly-Linked-List or Doubly-Linked-List, inserts are O(1), peeks are 
O(1) and removals are O(1). Compare that to an array based 
queue implementation where inserts are O(1) and peeks are O(1) but 
removals are O(n)... (or inserts and removals are reversed).


For low volume logic, the array can substitute for more custom data 
structures quite easily. But for needs with more data (or more 
transactions), there's no replacement for a proper data structure...




To the original question:

I would love to see not just more data structures, but better designed 
ones in core.


For example, with SPLStack http://php.net/manual/en/class.splstack.php
1. Why the heck does it have unshift() as well as push()? A stack is a 
One-way-in, one-way-out data structure, why are both exposed?
2. Why the heck does it implement ArrayAccess? Again, completely 
defeats the point of a stack
3. Why does it *extend* DLL? A Stack can be implemented with a DLL, 
but it is *not* a DLL. Huge difference...


Now, there was some discussion by some of us about re-doing the entire 
spl data structures a while ago. This git repo (PHP) is the evolution 
of that idea. https://github.com/morrisonlevi/Ardent


Now it's not written with the explicit intent of replacing SPL. It's 
written in an attempt to try to get the data structures designed 
right. Then, it may be ported to PECL, and then finally may be 
proposed to core.



As far as MAP, we already have one: 
http://php.net/manual/en/class.splobjectstorage.php
If you give a closer look to my example, you will notice a difference: 
$map[$setA] and $map[$setB] point to the same storage which I think is 
not possible with SPLObjectStorage.


My $0.02 at least,

Anthony





Re: [PHP-DEV] How about implementing more data structures (ie Map, Set)

2012-12-18 Thread Victor Berchet


On 12/18/2012 07:46 PM, Anthony Ferrara wrote:

Victor,


If you give a closer look to my example, you will notice a
difference: $map[$setA] and $map[$setB] point to the same storage
which I think is not possible with SPLObjectStorage.

Well, how could you do that? Without implementing object comparison 
methods at least (which is outside the scope of this discussion)? I 
could see a type-specific map which knows how to compare the classes, 
but in general you'd need to defer comparison to the objects 
themselves (so $obj1 == $obj2 would fire $obj1-compareTo($obj2) === 0)...


Unless I've got something confused...
Well let's say that object comparison methods (interface) is part of the 
details that I owe to this thread.