Talk:Amb: Difference between revisions

m
added a section hearder (name) to the 1st (unnamed) discussion (to put the TOC in the proper place).
(→‎Go: new section)
m (added a section hearder (name) to the 1st (unnamed) discussion (to put the TOC in the proper place).)
 
(4 intermediate revisions by 3 users not shown)
Line 1:
 
==A better sentence?==
"The Amb operator takes some number of expressions (or values if that's simpler in the language) and nondeterministically yields the one or fails if given no parameter, amb returns the value that doesn't lead to failure."
 
Line 15 ⟶ 17:
(This variant not really great but I believe it is accurate and complete). -- RDM 12:53, 27 August 2009 (EDT)
 
I've taken the plunge and clarified and expanded the description of the task.[[User:Kazinator|Kazinator]] ([[User talk:Kazinator|talk]]) 15:14, 31 October 2015 (UTC)
 
==Nondeterministic==
Line 20 ⟶ 23:
Can we assume, for the purposes of the task, that the pseudo-randomness of "random" numbers available on PCs without external assistance qualify as non-deterministic? --[[User:Short Circuit|Short Circuit]] 22:47, 22 March 2008 (MDT)
:The non-determinism is a red herring. No implementation of Amb I've seen is actually random. The important feature of Amb is backtracking via capturing the continuation. The result is something closer to exception handling. (Can Amb be implemented using only exceptions?)
::non-determinism doesn't mean randomness in computer science. This is clarified in the new task description.[[User:Kazinator|Kazinator]] ([[User talk:Kazinator|talk]]) 15:14, 31 October 2015 (UTC)
:This is an advanced (almost esoteric) concept covered in SICP among other places. See: http://c2.com/cgi/wiki?AmbSpecialForm [[wp:Continuation]]. --[[User:IanOsgood|IanOsgood]] 09:30, 24 March 2008 (MDT)
 
Line 38 ⟶ 42:
 
--[[User:Sluggo|Sluggo]] 22:20, 6 September 2009 (UTC)
: Non-termination presents a problem for continuations and threads also; they don't solve the issue at all of when a branch of the computation fails by not terminating! Processing is stuck there, that is all. Exception handling isn't in an of itself a solution; rather, nonlocal control transfers can support an explicit backtracking solution by providing a convenient direct branch to some earlier "top level" in cases when failure or success are confirmed.
 
For my part, and demonstrated by my VBScript entry, I don't think I understood the task at all. I don't think many did. Even after reading all this, I'm still not sure I do. I did have fun, all the same, coming up with the VBScript code. --[[User:Axtens|Axtens]] 08:47, 16 February 2010 (UTC)
Line 65 ⟶ 70:
== Go ==
 
I added a solution inspired more by [http://www-formal.stanford.edu/jmc/basis.html| McCarthy's original paper] than the SICP presentation. McCarthy talks about functions which may be "undefined" in some cases and says, "...when the computation process fails to terminate, the result is undefined." (bottom of p. 7 in the PDF.) The Go version handles this with channels and goroutinesgo routines.
 
: It seems they've taken down that server. Here's the Wayback Machine link: [https://web.archive.org/web/20120901194931/http://www-formal.stanford.edu/jmc/basis.html McCarthy's Paper via Wayback Machine] --[[User:Rabuf|Rabuf]] ([[User talk:Rabuf|talk]]) 17:09, 7 November 2013 (UTC)
:: It's still there, the wiki markup for the link was incorrect (I've corrected it). —[[User:dchapes|dchapes]] ([[User talk:dchapes|talk]] | [[Special:Contributions/dchapes|contribs]]) 14:19, 5 September 2014 (UTC)
 
He defines amb as a binary operator on x and y where either or both may be undefined. That is, x and y are separate computations which may or may not terminate. He talks of functions having possible values (plural) and while he doesn't specify that amb must enumerate its defined values, we assume so because we want to do backtracking. This binary enumerating amb can be composed into a form that works with multiple values. The result, in a context of computations that take an unknown amount of time, is a form that may yield a number of values, but perhaps not immediately, perhaps not all at once, perhaps never. A goroutine supplying values over a channel has this capability.