Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday June 09, 2008
05:27 PM

Stupid Perl 6 Ideas While Sick

[ #36635 ]

Somehow, being sick seems to bring out the stupid in me. Or maybe I'm brilliant. I don't know. However, I just realized that I want the following to be legal in Perl 6.

subset Crosshair of Point where {
    $_.inside_of($target_area)
    ||
    $target_area.has_moved
      ?? $_.move_inside($target_area)
      :: $target_area.move_outside($_)
};

In other words, I think I want subsets to be allowed to mutate their variable. If that works, I think we can allow proper constraint programming in Perl 6. With the above example, imagine dragging your crosshair and the target zone automatically moves. Or moving the target zone and your crosshair automatically stays inside. No funky rules need to get sprinkled in your code. It's built into the type definition!

The downside is mysterious "action at a distance". The upside is a powerful tool that was previously the domain of logic programming languages. Perl 6 is simple at its basic level (much simpler than Perl 5!), but its advanced capabilities can open up worlds of programming that we've not even thought of yet.

Update:

Jonathan Worthington said you can make that work with this:

subset Crosshair of Point where <-> $_ {
    $_.inside_of($target_area)
    ||
    $target_area.has_moved
      ?? $_.move_inside($target_area)
      :: $target_area.move_outside($_)
};

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.