You are here: Re: function "attributes" « PHP Programming Language « IT news, forums, messages
Re: function "attributes"

Posted by Jon Slaughter on 06/07/07 02:32

"Edward Z. Yang" <edwardzyang@thewritingpot.com> wrote in message
news:466767B5.3090901@thewritingpot.com...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jon Slaughter wrote:
>> is there any way to simply add an attribute like feature to a
>> function/method definition? [snip]
>
> You want the "Strategy" pattern, making the function into an object:
>
> class TestFunction
> {
> var $probability = 0.234321;
> function call() { /* ... */ }
> }
>
> $func = new TestFunction();
> $func->call();
>
> PHP does not treat anonymous functions as first-class objects, unlike
> JavaScript, so some acrobatics are necessary to get this working.

This is more work than I'm looking for unless I can someone "wrap" a
function into a functor.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация