by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jason Felice
    @eraserhd
    Ah, that is pushing the continuation "under" the stack... still doesn't help the no-satisfying-values case, unless you are willing to say that (begin-amb (required #f) (amb-collect #f)) ;=/=> ()
    vyzo
    @vyzo
    oh I see what you mean
    yeah, if required always fails then it can't collect anything
    in a sense there were no values produced
    Jason Felice
    @eraserhd
    I'm thinking amb-collect's original implementation was more correct, even though poorly documented (anywhere!!)
    vyzo
    @vyzo
    well it's limited
    it must be in the outer scope
    otherwise it doesn't collect shit
    I wouldn't call that more correct
    it's not part of the original paper either, so it was something the chicken peeps added
    Jason Felice
    @eraserhd
    if you think of it as "a different begin-amb", it makes sense.
    vyzo
    @vyzo
    yes, but we do have begin-amb and we can do more interesting things with it :)
    I really like having it inside the code and saying (all-of x) instead of having to say (all-of (let (blah (amb ...) ...) ...)
    Jason Felice
    @eraserhd
    Yeah, that is definitely nice.
    vyzo
    @vyzo
    alright, the extra parameter trick works
    I run it 100 times and no failure
    vyzo
    @vyzo
    alright, here is #531
    now it should work reliably
    check out this example:
    (begin-amb-random (let ((x (amb 1 2 3)) (y (amb 1 2 3))) (required (> x y)) (all-of (cons x y))))
    it's very declarative
    Jason Felice
    @eraserhd
    ok, building now
    vyzo
    @vyzo
    also note that thanks to begin-amb and the use of parameters we can have nested ambs very easily
    which is not possible in chicken, because they use global variable mutation to track continuations
    Jason Felice
    @eraserhd
    that is very nice
    vyzo
    @vyzo
    plus multiple threads doing ambs at the same time
    don't try that in chicken :)
    vyzo
    @vyzo
    Actually I think I should use amb-end in one-of as well
    it's really nice that we have the second parameter
    Jason Felice
    @eraserhd
    still building... so how does emacs detect that a file is gerbil instead of scheme?
    Do you configure emacs so that all .ss files are gerbil?
    amb-collect is working for me (except, of course, that I'll need to handle the no-values case)
    vyzo
    @vyzo
    I am also exporting the exception predicate now
    will push shortly
    updating the documentation
    so that you can catch the exception
    and do something meaningful in the no values case
    alright, pushed
    is it just me or is github acting up for everyone today?
    so for the emacs detection
    vyzo
    @vyzo
    1) I have set .ss files to default to gerbil mode
    2) I also use the modline, all gerbil code has -*- Gerbil -*- in it
    so handling the no values case:
    (try do-some-amb-stuff-and-collect (catch (amb-exhausted? e) []))
    vyzo
    @vyzo
    also note that all-of still works outside the amb expression
    this works:
    (begin-amb-random (all-of (let ((x (amb 1 2 3)) (y (amb 1 2 3))) (required (> x y)) (cons x y))))
    so we are backwards compatible
    and if the constraint is not satisfied, it will return the empty list
    vyzo
    @vyzo
    alright, merged