in reply to Firefly

Very nice. Too bad you had to change "You can't take the sky from me" to "take sky" though... Still ++.

--
Let's be bad guys. Random Synapse Firing

Replies are listed 'Best First'.
Re^2: Firefly
by tirwhan (Abbot) on Nov 11, 2005 at 15:20 UTC

    Thanks for the comment and upvote! Take a look at the take subroutine. It returns "You can't take the sky from me" when called as take sky, but otherwise puts the thing taken into the recipient. It doesn't do anything with the output, because otherwise you'd have this printed out three times around the other output, which felt ugly. Seemed appropriate to me ;-).


    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
Re^2: Firefly
by dragonchild (Archbishop) on Nov 11, 2005 at 15:30 UTC
    "You can't take the sky from me." ... hrmm ... We can get creative here.
    • If one takes Buber's I and Thou literally, "you" would be anything outside the program. In the context of Perl, that would be STDIN, STDOUT, @ARGV, ... and %ENV. As the first 2 are filehandles and the third is an array, let's work with %ENV.
    • "take" is going to be a keyword in Perl6, but we don't have that yet. So, let's think about taking ... when you take from me, that is the same as removing something from my possession. We could use any number of functions that "take", like substr, chop/chomp, etc. The problem is representing the negation of these.
    • The iconic representation of the program is $0, so we'll use that for "me". Now, if we tie me, we can override FETCH.
    • Sky ... look below.
    package Me; TIESCALAR { bless \(my $x = $_[1]), $_[0] } FETCH { die "cannot take it away" } package main; tie $0, Me; eval { $ENV{'you'} = $0 =~ s/sky//; 1 } || print $@;

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?