Everett has written a lot of code in it. I've encouraged him to send a
mail about his experience... hopefully he will soon ;)
Jay
On Mon, Oct 11, 2010 at 6:05 PM, Shriram Krishnamurthi
wrote:
> Good of you to dogfood. I didn't really get turned on by alt-exp from
> your previous post, but it's
Good of you to dogfood. I didn't really get turned on by alt-exp from
your previous post, but it's cool that you can express this!
_
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
Here's mine, probably not a very good way to implement this, but it
works and it uses the alt-exp syntax I've been playing with recently.
#lang alt-exp
#|
Spec: define a case construct syntactically just like that of Racket.
In terms of semantics:
- each branch automatically falls through to
David Herman wrote at 10/09/2010 11:22 PM:
I think maybe we're not disagreeing about anything at all. I wasn't arguing that
splitting up the `case' is better -- I actually prefer the version that has one single
`case'. My point was just that some of the earlier versions which did a repeated "am
> Probably I'm missing something, since you know the compiler better than I do.
Not in the least; my points are pretty much abstract/academic.
> My understanding is that your code prescribes a series of branching tests,
> rather than giving the compiler a single n-way "case" and letting the
> c
On Sat, Oct 9, 2010 at 10:30 PM, David Herman wrote:
> I think you may be missing a crucial point: once control hits the
> first passing test, there are no more conditionals; every right-hand
> side is compiled as a procedure that unconditionally tail-calls the
> next right-hand side.
This is ho
David Herman wrote at 10/09/2010 10:30 PM:
I think you may be missing a crucial point: once control hits the first passing
test, there are no more conditionals; every right-hand side is compiled as a
procedure that unconditionally tail-calls the next right-hand side. IINM, this
is pretty much
I think you may be missing a crucial point: once control hits the first passing
test, there are no more conditionals; every right-hand side is compiled as a
procedure that unconditionally tail-calls the next right-hand side. IINM, this
is pretty much the same way `switch' is typically compiled:
David Herman wrote at 10/09/2010 07:46 PM:
I thought about the "am I falling through?" approach you've been taking, but the problem
is that it keeps having to recompute the same test. In C-like languages, one of the benefits of
`switch' [1] is that fall-through is expected to either be a litera
On Sat, Oct 9, 2010 at 8:00 PM, David Herman wrote:
> Ah, yes, I didn't see Carl's solution, which is pleasantly concise and
> particularly nice because of the single case.
> But I still think the point about fall-through is important to the
> performance model of `switch' -- it's what Duff's De
I've been feeling pretty good about my macro-fu recently so I gave it a shot
(I havent looked at anyone's solutions yet). This seems to pass all the test
cases but I dont think it passes the "linear" requirement yet.
(define-syntax (cas-cad-e stx)
(syntax-case stx ()
[(_ e ((v) exp ...))
(
Ah, yes, I didn't see Carl's solution, which is pleasantly concise and
particularly nice because of the single case. But I still think the point about
fall-through is important to the performance model of `switch' -- it's what
Duff's Device relies on, for example.
If you care about constructs l
This looks a lot like Carl's (and my modification of it.)
Jay
On Sat, Oct 9, 2010 at 5:46 PM, David Herman wrote:
> I thought about the "am I falling through?" approach you've been taking, but
> the problem is that it keeps having to recompute the same test. In C-like
> languages, one of the b
I thought about the "am I falling through?" approach you've been taking, but
the problem is that it keeps having to recompute the same test. In C-like
languages, one of the benefits of `switch' [1] is that fall-through is expected
to either be a literal "execute the next instruction in the PC" o
On Fri, Oct 8, 2010 at 10:04 PM, Shriram Krishnamurthi
wrote:
> One of my students recently sent me this needless email message:
>
>> Well, how would you do switch fall-through in Scheme? Could you
>> write a version of the case statement that does that?
>
> Since the honor of Racket was at stake
Here is yet another solution.
The focus of this one is not to be short, but rather to provide
error messages that refer to cas-cad-e and not to constructs
that cas-cad-e expands to.
Extra tests are provided.
--
Jens Axel Søgaard
cas-cad-e-test.rkt
Description: Binary data
cas-cad-e.rkt
Descr
2010/10/9 Shriram Krishnamurthi :
> Spec: define a case construct syntactically just like that of Racket.
> In terms of semantics:
> - any branch can contain (break ), which evaluates and
> returns its value as that of the entire case.
In
(let ([break 1])
(cas-cad-e 5
((1) (displ
The semantics is defined as:
> Spec: define a case construct syntactically just like that of Racket.
> In terms of semantics:
> - the last one returns its answer since it has no next clause, and
Does this imply that a cas-cad-e expression must contain at least
one clause?
--
Jens Axel Søgaard
I just made a small change the removes the useless 'start' procedure.
(The first change removed the 'final')
Jay
On Sat, Oct 9, 2010 at 8:37 AM, Jay McCarthy wrote:
> Carl, yours doesn't pass the test suite.
>
> For example, you return (void) rather than 3.
>
> I've fixed that, removed the letre
Carl, yours doesn't pass the test suite.
For example, you return (void) rather than 3.
I've fixed that, removed the letrec and added else support.
http://github.com/jeapostrophe/exp/blob/master/cas-cad-e.rkt
Jay
On Sat, Oct 9, 2010 at 7:52 AM, Carl Eastlund wrote:
> Here's my solution. It is
Here's my solution. It is pure (if you ignore the set! nature of
letrec), has linear expansion, avoids multiple values, and uses a
single "case" for conditional tests. The only thing it lacks that I
know of is support for "else".
--
> Regarding Shriram's bug. The only thing that occurs to me is that
> you'd want eqv? and a ' on the ns, to be more like case.
Yep. I got it for free by reusing case.
Shriram
_
For list-related administrative tasks:
http://lists.racket-lang.org
I don't really like have the call-with-values and apply there, so
here's another version. It makes the macro a bit longer with the
additional case and has the pattern duplicated once, but it seems
worth it:
(define-syntax cas-cad-e
(syntax-rules ()
[(_ e) (begin e (void))]
[(_ e [(n ...)
Can that mutation can be exposed by call/cc?
Robby
On Fri, Oct 8, 2010 at 11:09 PM, Jay McCarthy wrote:
> Mutation that is invisible to the user is fine by me.
>
> Jay
>
> Sent from my iPhone
>
> On Oct 8, 2010, at 10:04 PM, Neil Van Dyke wrote:
>
>> Jay McCarthy wrote at 10/08/2010 11:41 PM:
>
Cute.
Since everyon'e s snarky wiseass, I might as well point out that both
Eli's and Jay's have a subtle bug. Hint: they're 2-3 characters off.
Shriram
_
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
You got me
Sent from my iPhone
On Oct 8, 2010, at 10:33 PM, Eli Barzilay wrote:
> 8 minutes ago, Jay McCarthy wrote:
>> Alright, here's the version with no mutation:
>
> (cas-cad-e 1 [(1) (values 1 2 3)])
>
> In other words:
>
> (define-syntax-rule (cas-cad-e e [(n ...) code ...] ...)
> (le
8 minutes ago, Jay McCarthy wrote:
> Alright, here's the version with no mutation:
(cas-cad-e 1 [(1) (values 1 2 3)])
In other words:
(define-syntax-rule (cas-cad-e e [(n ...) code ...] ...)
(let/ec esc
(syntax-parameterize ([break (make-rename-transformer #'esc)])
(let*-values ([(tm
Alright, here's the version with no mutation:
(define-syntax-rule (cas-cad-e e [(n ...) code ...] ...)
(let/ec esc
(syntax-parameterize
([break (make-rename-transformer #'esc)])
(let*-values
([(tmp) e]
[(earlier? ret) (values #f (void))]
[(earlier? ret)
Mutation that is invisible to the user is fine by me.
Jay
Sent from my iPhone
On Oct 8, 2010, at 10:04 PM, Neil Van Dyke wrote:
> Jay McCarthy wrote at 10/08/2010 11:41 PM:
>> I wrote mine without looking at Elis. I like his and mine better than the
>> others. And obvs I like mine more. =P
>>
Jay McCarthy wrote at 10/08/2010 11:41 PM:
I wrote mine without looking at Elis. I like his and mine better than the
others. And obvs I like mine more. =P
Mutation?! :)
I suppose that these different solutions might hint at some of our
varying styles or priorities.
My use of "syntax-rul
20 minutes ago, Jay McCarthy wrote:
> I wrote mine without looking at Elis. I like his and mine better than
> the others. And obvs I like mine more. =P
Heh -- I almost did something very close to that, but then got tempted
to do something without the mutations.
--
((lambda (x) (x x)) (
I wrote mine without looking at Elis. I like his and mine better than
the others. And obvs I like mine more. =P
#lang racket
(require racket/stxparam)
(define-syntax-parameter break
(λ (stx) (raise-syntax-error 'break "Used outside cas-cad-e" stx)))
(define-syntax-rule (cas-cad-e e [(n ...) code
15 minutes ago, Neil Van Dyke wrote:
> Eli Barzilay wrote at 10/08/2010 10:57 PM:
> > Here's a much shorter version that doesn't require goto emulation,
>
> Nice. On principle, I was going to trouble to avoid redundant
> tests, as well as give the compiler a single optimization-friendly
> "case"
Eli Barzilay wrote at 10/08/2010 10:57 PM:
Here's a much shorter version that doesn't require goto emulation,
Nice. On principle, I was going to trouble to avoid redundant tests, as
well as give the compiler a single optimization-friendly "case" form,
followed by tail calls. In practice, I
Shriram Krishnamurthi wrote at 10/08/2010 10:42 PM:
"it was unclear ... so I restricted" = the refuge of rogues.
Pirates of the Ambiguous Specification
--
http://www.neilvandyke.org/
_
For list-related administrative tasks:
http://lists.racket
Here's a much shorter version that doesn't require goto emulation, and
is also almost syntax-rules-kosher, modulo a syntax parameter for
breaking:
---
#lang racket
(provide cas-cad-e)
(require racket/stxparam)
(define-s
> Note that it was unclear to me where the "break" form could appear,
> so I restricted it to being at the end of the clause, like how
> people typically use "break" in C-like "switch" forms.
"it was unclear ... so I restricted" = the refuge of rogues.
Here's a test that my version passes:
(defi
Shriram Krishnamurthi wrote at 10/08/2010 09:04 PM:
http://github.com/shriram/cas-cad-e
And using "syntax-rules":
http://www.neilvandyke.org/weblog/2010/10/#2010-10-08
Note that it was unclear to me where the "break" form could appear, so I
restricted it to being at the end of the clau
Oh, and you should make sure your solution generates code that is
linear in the size of the input. Someone just sent me a solution that
works, but I'm pretty sure is quadratic.
Shriram
_
For list-related administrative tasks:
http://lists.racket
One of my students recently sent me this needless email message:
> Well, how would you do switch fall-through in Scheme? Could you
> write a version of the case statement that does that?
Since the honor of Racket was at stake (yes, we can have all the same
stupid features the scripting languages
40 matches
Mail list logo