Re: function -> action

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, August 10, 2007 9:40 am, Martin Alterisio wrote:
> 2007/8/7, Richard Lynch <ceo@xxxxxxxxx>:
>>
>> On Fri, August 3, 2007 1:38 am, Ralph Kutschera wrote:
>> >   I'm working on a project, where we distinguish between
>> "functions"
>> > and
>> > "actions" in design, although in PHP both are implemented as
>> > functions.
>> > Is there a chance that PHP can use the word "action" as
>> "function"?
>> >
>> > E.g.:
>> > public function doSomething() { .... }
>> > public action doSomethingElse() { ... }
>> >
>> > ... is actually the same but would help to see the design also in
>> the
>> > code.
>>
>> You might be able to do this with the Run-Kit extension...
>
>
> I was unaware that run-kit was able to do this kind of things, could
> you
> explain a little more about how would this extension could handle code
> with
> alien keywords.

I do not know exactly what the Run-Kit extension allows you to
re-define -- I only know that it lets you re-define a LOT of low-level
PHP stuff on the fly...

It may not be possible at all to introduce a new keyword with run-kit.

> It might be easier, however, to hack some kind of pre-processor that
>> would search for PCRE '\\s*action\\s*' and replace it with '
>> function
>> '
>>
>> You'd have to pre-process generate your actual PHP files that get
>> executed, but the source you use would just have the 'action' in it.
>
> Actually is not that simple. There are some considerations that should
> be
> taken into account, such as the loss of error information (file and
> line
> number where the error occurs) and exception information (stack trace
> does
> not point to the right place), and parsing correctly the code as to
> replace
> the action keyword where it actually applies. I made some
> experimentation
> with preprocessing php code with added keywords, that might help you
> if you
> wish to use such a solution:
> http://www.phpclasses.org/browse/package/4001.html

If one is simply mapping:
public action foo

into:
public function foo

then the line number isn't going to change, and, assuming you've been
reasonable about generating the real PHP code, the filename won't
change, just the directory.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux