by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    vyzo
    @vyzo
    so that when amb-do exhausts the loop jumps into returning the collected values
    Jason Felice
    @eraserhd
    Then begin-amb throws at the end if there are no values?
    er, hmm
    vyzo
    @vyzo
    the problem is that amb-do changes the continuation to loop, but when it fails it calls the original fail that was saved prior to entering the loop
    Jason Felice
    @eraserhd
    What should it do?
    vyzo
    @vyzo
    give me a few more, I am trying to fix it :)
    Jason Felice
    @eraserhd
    np!
    vyzo
    @vyzo
    I need to propagate the continuation from within collect
    no wonder the chicken version doesn't work at all and wants to have ambs inside the collect :p
    this is tricky business
    Jason Felice
    @eraserhd
    I think that can't handle the case where the code is unsatisfiable, though.
    vyzo
    @vyzo
    I am going to patch the terminal failure (amb-exhausted) to use a second parameter to propagate from collect
    so if it fails and there is a collect continuation, it's going to invoke that instead
    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