Re: Overloaded functions and function pointers in PHP?



Oli Filth <catch@xxxxxxxxxxxxxx> wrote:
> Peter Salzman said the following on 10/09/2005 17:21:
> >
> > Here's why I'm asking. Consider these two function:
> >
> >
> > function foo( $arg ) { echo "foo $arg foo\n"; }
> >
> > function bar() { echo "barfoo"; }
> >
> >
> > I'd like to be able to do this:
> >
> > foo('hello');
> > foo(&bar());
> >
> > to produce this:
> >
> > foo hello foo
> > foo barfoo foo
> >
>
> How about:
>
> function foo($arg)
> {
> echo "foo $arg foo\n";
> }
>
> function bar()
> {
> return "barfoo";
> }
>
> foo(bar());


The function argument seems to be executing before the call to foo is made.
In my own code, I'm getting the equivalent of:

barfoo foo foo

rather than

foo barfoo foo


Pete
.



Relevant Pages

  • Re: unset($this) or maybe unset(&$this)
    ... which does not involve a jump is executed the next instruction to be executed will be the very next instruction in the same object method. ... The code may still exist in the class definition, but the object, which contains a copy of that code in memory, does not, so how can it continue executing any of that code? ... When you call something like obj.Func; in C++ (assuming obj is an instance of class Foo), the compiler actually translates that to something like: ...
    (comp.lang.php)
  • Re: What should (ignore-errors ((foo))) do?
    ... On the other hand, since (foo) can't be macroexpanded without error, ... choose to compile the fragment before executing it, ... CLISP appears to expand before the form is executed. ... SBCL does't signal an error until the second line, even though compile ...
    (comp.lang.lisp)
  • Re: Really good idea to allow mmap(0, FIXED)?
    ... struct s *foo; ... and if there is some way that userland code can cause this to be ... executed with 'foo' set to a NULL pointer, ... The security exploit I explained didn't involve executing anything ...
    (Linux-Kernel)
  • difference between class statement and def statement (WAS Re: End of file)
    ... > def foo(): print foo ... class definition statement and a function definition statement. ... class definition statement executes the class block, while executing a ... The name of a function is bound to the function object when the def statement ...
    (comp.lang.python)
  • Re: Is setTimeout() asynchronous?
    ... so the return value of foo() won't ... > user if my long running function takes more than n milliseconds] ... yield() in order to allow other code to be executed. ...
    (comp.lang.javascript)