Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re (tilly) 1: Apocalypse 3

by tilly (Archbishop)
on Oct 04, 2001 at 16:32 UTC ( [id://116677]=note: print w/replies, xml ) Need Help??


in reply to Apocalypse 3

Hmmm...

:=, laziness, he is thinking big. I hope he thinks through the consequences. Otherwise he may just find me submitting a bug report about the following code:

$x := $y + 5; $y := $x -3; print "Answer: ($x, $y)\n";
Unless, of course, it works. In which case I shall probably sacrifice burnt offerings at TheDamian's altar. (And then try to break it with a non-linear system of equations.)

In a similar and more reasonable vein, I hope that his thinking about laziness, :=, and slice mechanics goes far enough that you can readily (for instance) define the Fibonacci sequence as a lazy list and have it work right...

Replies are listed 'Best First'.
Re: Re (tilly) 1: Apocalypse 3
by TheDamian (Vicar) on Oct 05, 2001 at 12:19 UTC
    I'm afraid := isn't the fully fledged unification operator you're hoping for. As I'll explain in Exegesis 3, it's really just an aliasing mechanism.

    So your declarative emergent $x and $y values aren't actually being declared, or emerging either. :-(

    In fact, you'd just get $x aliased to the (constant) result of $y+5 (which will be 5 if there's no prior assignment to $y), and then $y aliased to the (constant) result of $x-3 (which will be 2 under the previous assumption).

    However, as a consolation prize for having suggested human sacrifice to me (you did intend it to be a human burnt offering, didn't you???), I have now added a Data::Unification module to my ToDo list. ;-)

    Damian

      Hi Damian,

      In the Section "Applied Laziness 101" of the third Exegesis, you wrote:
      Of course, if we'd written:

      my ($name, $vers, $status, $costs, @and_the_rest) = <fh>;

      The the entire file would have been read
      Did you mean:

      my ($name, $vers, $status, $costs, *@and_the_rest) = <fh>;

      or will array assignment work differently on the diamond operator?

      Simon Flack ($code or die)
      $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
      =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
        Did you mean:
        my ($name, $vers, $status, $costs, *@and_the_rest) = <fh>;


        No. I did mean just what I wrote.

        Regular = assignments have the same "slurp-it-all-up" semantics as in Perl 5.

        The flattening asterisk is only required in subroutine parameter lists or := bindings.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://116677]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found