<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-876358347971598886.post7817256343130860240..comments</id><updated>2009-09-06T03:15:01.871+03:00</updated><title type='text'>Comments on nothingmuch's perl blog: Abstracting Ambiguity</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.woobling.org/feeds/7817256343130860240/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html'/><author><name>nothingmuch</name><uri>http://www.blogger.com/profile/03975438115490089158</uri><email>nothingmuch@woobling.org</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-6689058892414494257</id><published>2009-09-06T03:15:01.871+03:00</published><updated>2009-09-06T03:15:01.871+03:00</updated><title type='text'>You might find this old post of mine about doing s...</title><content type='html'>You might find this old post of mine about doing some continuation based declarative coding in Perl of mild interest&lt;br /&gt;&lt;br /&gt;http://www.perlmonks.org/?node_id=193649&lt;br /&gt;&lt;br /&gt;it&amp;#39;s a nice model for those times I miss Prolog :-)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/6689058892414494257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/6689058892414494257'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1252196101871#c6689058892414494257' title=''/><author><name>Adrian Howard</name><uri>http://www.blogger.com/profile/07129653155892872494</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-5555858048291749593</id><published>2009-08-27T03:12:40.811+03:00</published><updated>2009-08-27T03:12:40.811+03:00</updated><title type='text'>I can't wait to play with this!

I found a similar...</title><content type='html'>I can&amp;#39;t wait to play with this!&lt;br /&gt;&lt;br /&gt;I found a similar backtracking example in &lt;a href="http://www.iro.umontreal.ca/%7Eboucherd/mslug/meetings/20041020/90-min-scc/90-min-scc.pdf" rel="nofollow"&gt;scheme&lt;/a&gt; a while back and ported it to Ruby (1.8):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pastie.org/596143" rel="nofollow"&gt;http://pastie.org/596143&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I wrote a perl version as well using &lt;a href="http://search.cpan.org/perldoc?Coro::State" rel="nofollow"&gt;Coro::State&lt;/a&gt;, but it&amp;#39;s untested because I never got round to configuring support for the continuation &amp;quot;game&amp;quot; (as Marc Lehmann calls it) in Coro (it uses the callcc implementation from the POD):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pastie.org/596157" rel="nofollow"&gt;http://pastie.org/596157&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/5555858048291749593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/5555858048291749593'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1251331960811#c5555858048291749593' title=''/><author><name>chocolateboy</name><uri>http://www.blogger.com/profile/08409735001739000046</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-4688635401695380036</id><published>2009-08-25T12:52:31.440+03:00</published><updated>2009-08-25T12:52:31.440+03:00</updated><title type='text'>I was thinking of a related acme module, basically...</title><content type='html'>I was thinking of a related acme module, basically an object that overloads all operators to do predicate unification and when it&amp;#39;s resolved into an actual value (e.g. &amp;#39;&amp;quot;&amp;quot;&amp;#39; or &amp;#39;+0&amp;#39; overloading) that invokes amb as a thunk, and returns some value that satisfies the constraints.&lt;br /&gt;&lt;br /&gt;Comparators in void context become assertions:&lt;br /&gt;&lt;br /&gt;$x == $y; # this is true&lt;br /&gt;&lt;br /&gt;and we get instant prolog.&lt;br /&gt;&lt;br /&gt;The problem is that I have no idea how to capture continuations with actual C stack frames (i don&amp;#39;t think that&amp;#39;s even possible in a portable way), so that kills overloading.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/4688635401695380036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/4688635401695380036'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1251193951440#c4688635401695380036' title=''/><author><name>nothingmuch</name><uri>http://www.blogger.com/profile/03975438115490089158</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='04344917020781355723'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-2275265416327196547</id><published>2009-08-25T07:48:42.708+03:00</published><updated>2009-08-25T07:48:42.708+03:00</updated><title type='text'>You could use this for solving problems like this:...</title><content type='html'>You could use this for solving problems like this:&lt;br /&gt;&lt;br /&gt; send + more = money&lt;br /&gt;&lt;br /&gt;for my $l (split &amp;quot;&amp;quot;, &amp;quot;sendmorny&amp;quot;) {&lt;br /&gt;  $l{$l} = amb(0..9);&lt;br /&gt;  $$l = $l{$l};&lt;br /&gt;}&lt;br /&gt;# must be unique&lt;br /&gt;my %vals = map { $_ =&amp;gt; 1 } values %l;&lt;br /&gt;amb_assert(keys(%vals) == keys(%l));&lt;br /&gt;&lt;br /&gt;# run off the expression&lt;br /&gt;my $cry;&lt;br /&gt;amb_assert(($cry=$d + $e)%10 == $y);&lt;br /&gt;$cry = ($cry &amp;gt; 9 ? 1 : 0);&lt;br /&gt;amb_assert(($cry=$n + $r + $cry)%10 == $e);&lt;br /&gt;$cry = ($cry &amp;gt; 9 ? 1 : 0);&lt;br /&gt;amb_assert(($cry=$e + $o + $cry)%10 == $n);&lt;br /&gt;$cry = ($cry &amp;gt; 9 ? 1 : 0);&lt;br /&gt;amb_assert(($cry=$s + $m + $cry)%10 == $o);&lt;br /&gt;$cry = ($cry &amp;gt; 9 ? 1 : 0);&lt;br /&gt;amb_assert($cry == $m);&lt;br /&gt;&lt;br /&gt;$string = &amp;quot;$s$e$n$d + $m$o$r$e == $m$o$n$e$y&amp;quot;;&lt;br /&gt;amb_assert(eval $string);&lt;br /&gt;print &amp;quot;$string\n&amp;quot;;&lt;br /&gt;&lt;br /&gt;see also &lt;a href="http://mail.pm.org/pipermail/wellington-pm/2005-March/000293.html" rel="nofollow"&gt;my experiments with Junctions from 2005&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/2275265416327196547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/2275265416327196547'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1251175722708#c2275265416327196547' title=''/><author><name>SamV</name><uri>http://www.blogger.com/profile/15104557254324587099</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-2145465180885194383</id><published>2009-08-24T14:09:34.425+03:00</published><updated>2009-08-24T14:09:34.425+03:00</updated><title type='text'>You can do that in Haskell because every expressio...</title><content type='html'>You can do that in Haskell because every expression in a do block is an implicit lambda and you can control the way they are sequenced based on the typeclass of the data involved.&lt;br /&gt;&lt;br /&gt;Since mbind is effectively the increment-the-instruction-pointer operation for any data that is relevant or interesting, they are a more generic abstraction than continuations.&lt;br /&gt;&lt;br /&gt;Unsurprisingly, continuations in Haskell are implemented in terms of a monad (which also makes the implementation very clean and simple, since mbind is already effectively CPS and there&amp;#39;s no mutable data).&lt;br /&gt;&lt;br /&gt;In Perl 6 this could theoretically still be done (e.g. by rewriting the AST) but in Perl 5 I am not sure there is a way to do this without suffering brain damage.&lt;br /&gt;&lt;br /&gt;B::Generate is not stable enough and there are no APIs for compiling new lexical pad structures and assigning indices, it would be a massive effort (but if done the results would be awesome).&lt;br /&gt;&lt;br /&gt;I guess by walking the optree and annotating some sort of ANF representation (op_next is pretty much ANF if you squint right) you could generate a minimal syntactic unit for new symbol introduction and convert all expressions into implicit subroutines, and then reparse that, but I think that&amp;#39;ll end up being pretty brittle.&lt;br /&gt;&lt;br /&gt;Anyway, if anyone has read this far, real monads are the next step ;-)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/2145465180885194383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/2145465180885194383'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1251112174425#c2145465180885194383' title=''/><author><name>nothingmuch</name><uri>http://www.blogger.com/profile/03975438115490089158</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='04344917020781355723'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-1443540610896198432</id><published>2009-08-24T13:59:05.695+03:00</published><updated>2009-08-24T13:59:05.695+03:00</updated><title type='text'>Or you can overload control flow and data at the s...</title><content type='html'>Or you can overload control flow and data at the same time...&lt;br /&gt;&lt;br /&gt;do { &lt;br /&gt;x &amp;lt;- [1,2,3];&lt;br /&gt;y &amp;lt;- [1,2,3];&lt;br /&gt;guard (x &amp;gt; 2);&lt;br /&gt;guard (x + y == 5);&lt;br /&gt;guard (y &amp;lt;= 2);&lt;br /&gt;return (show x ++ &amp;quot; + &amp;quot; ++ show y ++ &amp;quot; = 5&amp;quot;)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;A major contributor to my stifled inspiration for Perl 6 was realizing how much Junctions wanted to be Monad [].  But it was no fault of the Junctions: it was their society keeping them from realizing their true potential.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/1443540610896198432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/1443540610896198432'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1251111545695#c1443540610896198432' title=''/><author><name>Luke Palmer</name><uri>http://www.blogger.com/profile/09807388788677769669</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-876358347971598886.post-7760092057077200084</id><published>2009-08-24T11:35:08.223+03:00</published><updated>2009-08-24T11:35:08.223+03:00</updated><title type='text'>In case you didn't see this: http://search.cpan.or...</title><content type='html'>In case you didn&amp;#39;t see this: http://search.cpan.org/dist/Amb/</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/7760092057077200084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876358347971598886/7817256343130860240/comments/default/7760092057077200084'/><link rel='alternate' type='text/html' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html?showComment=1251102908223#c7760092057077200084' title=''/><author><name>kappa</name><uri>http://www.blogger.com/profile/10283564172364338483</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.woobling.org/2009/08/abstracting-ambiguity.html' ref='tag:blogger.com,1999:blog-876358347971598886.post-7817256343130860240' source='http://www.blogger.com/feeds/876358347971598886/posts/default/7817256343130860240' type='text/html'/></entry></feed>