in reply to Re: how to write a modified return() call?
in thread how to write a modified return() call?

Thank you, this is useful!

Two questions.. One on topic and one off topic.

  1. You say..
    my $start_with = another_value() or ( warn("Could not get another value"), return );
    Why not..
    my $start_with = another_value() or warn("Could not get another value"), return;
    Or even
    my $start_with = another_value() or warn "Could not get another value", return;
    I tried these out and they seem to work fine. I suppose it's maybe trying to mess with the compiler/interpreter being vague with arguments to warn(), in the last example.

    Are you using parenthesis as good practice/legibility only?

  2. It seems that unless I want to create my own perl distro, there's no way to do as JavaFan suggests ( 779943 ).

    Perl's pretty freaking liberal with what it lets you do with symbol tables, but.. we can't just add another function to the language at compile time.

    I wonder if this is something lisp could do- probably not- this must be on the language design (compiler/interpreter) level, not the coding level (?).
    ( Actually, as Corion noted initially.. 779928 )

Replies are listed 'Best First'.
Re^3: how to write a modified return() call?
by ikegami (Patriarch) on Jul 14, 2009 at 19:05 UTC

    Why not..

    I didn't check the relative precedence of "or" and ",". I also liked the visual grouping.

    Or even

    No, it doesn't work. It returns before evaluating warn.

    It seems that unless I want to create my own perl distro, there's no way to do as JavaFan suggests

    What JavaFan suggested works as is. If you mean to make it pretty... The best way probably would require language-level support.

    we can't just add another function to the language at compile time

    I guess it depends on what you mean by function. Out of context, I'd say that's not true.