Hi racketeers,
I would second this suggestion. Although it might look slightly
un-rackety at first sight, for certain types of code flow it does the
job really well.
And most importantly - I am using escape continuations in much wilder
setup (yes, futures) and it imposes no noticeable
I'm not sure if this is exactly what you want, but the handy module (which
I still need to split up into less of a Fibber McGee) includes handy/try.
This would let you do the following:
#lang racket
(require handy/try)
(define x (random 100))
; these are obviously silly functions that are only
On Wed, Oct 28, 2020 at 03:54:29AM -0700, Jack Firth wrote:
> So I'm a little tired of writing code like this:
>
> (define x ...)
> (cond
> [(take-shortcut? x) (shortcut x)]
> [else
>(define y (compute-y x))
>(cond
> [(take-other-shortcut? x y) (other-shortcut x y)]
> [else
>
Ryan's solution is almost certain to be nicer, but if you do find yourself
needing internal definition contexts now or in the future, this is similar
to a case I ran into while adding `define` to a language implemented with
Turnstile.
I wrote a blog post outlining the solution [1], which I
This is a nice example of a macro design pattern that I think of as
"partial expansion with trampolining". You don't need to deal with the
internal definition context API, because you can return definitions to the
macro expander, let it handle their interpretation, and then resume your
work.
The most similar example that comes to mind is the way `for`-like forms
handle the `body-or-break` nonterminal to support `#:break` and `#:final`.
In particular, I think you would end up needing something analogous to these
semantics for definitions
I've also had the same issues for a long time, and condd was almost good
enough, but the #:do is too specific.
But recently I'm using something much simpler (no continuation) and
straightforward: cond/else
https://github.com/Metaxal/bazaar/blob/master/cond-else.rkt
By contrast to other
Are you looking for `let/ec`?
(let/ec return
(define x (random 10))
(unless (even? x)
(log-info "x wasn't even, x = ~a" x)
(return -1))
(define y (random 10))
(unless (even? y)
(log-info "y wasn't even, y = ~a" y)
(return -1))
(+ x y))
Alex.
On Wednesday, October 28,
So I'm a little tired of writing code like this:
(define x ...)
(cond
[(take-shortcut? x) (shortcut x)]
[else
(define y (compute-y x))
(cond
[(take-other-shortcut? x y) (other-shortcut x y)]
[else
(define z ...)
(cond ...)])])
That is, I have some logic and that logic
Racket talks are extremely welcome at BOB!
BOB Conference 2021
"What happens when we use what's best for a change?"
http://bobkonf.de/2021/cfc.html
Berlin, February 26
Call for Contributions
10 matches
Mail list logo