Re: [racket-users] Cannot use case+else inside match+else

2019-02-27 Thread Shu-Hung You
And because it is nothing else but a usual binding, it's possible to
prefix-in or rename-in as in

(require (prefix-in r: racket/base))
(case 5 [r:else 'ok])

On Wed, Feb 27, 2019 at 7:32 AM Laurent  wrote:
>
> Good point. I wasn't sure that would work---it does.
>
> On Wed, Feb 27, 2019 at 1:28 PM Jens Axel Søgaard  
> wrote:
>>
>> I suppose you could (re)require it again.
>>
>> ons. 27. feb. 2019 kl. 14.19 skrev Laurent :
>>>
>>> Wait, that means that in an interactive session, if you ever happen to 
>>> redefine `else', you can't use `case' anymore?
>>>
>>> On Tue, Feb 26, 2019 at 5:03 AM Ben Greenman  
>>> wrote:

 Here's a suggestion for the docs:

 https://github.com/racket/racket/pull/2505

 --
 You received this message because you are subscribed to the Google Groups 
 "Racket Users" group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> --
>> Jens Axel Søgaard
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-27 Thread Laurent
Good point. I wasn't sure that would work---it does.

On Wed, Feb 27, 2019 at 1:28 PM Jens Axel Søgaard 
wrote:

> I suppose you could (re)require it again.
>
> ons. 27. feb. 2019 kl. 14.19 skrev Laurent :
>
>> Wait, that means that in an interactive session, if you ever happen to
>> redefine `else', you can't use `case' anymore?
>>
>> On Tue, Feb 26, 2019 at 5:03 AM Ben Greenman 
>> wrote:
>>
>>> Here's a suggestion for the docs:
>>>
>>> https://github.com/racket/racket/pull/2505
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> --
> Jens Axel Søgaard
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-27 Thread Jens Axel Søgaard
I suppose you could (re)require it again.

ons. 27. feb. 2019 kl. 14.19 skrev Laurent :

> Wait, that means that in an interactive session, if you ever happen to
> redefine `else', you can't use `case' anymore?
>
> On Tue, Feb 26, 2019 at 5:03 AM Ben Greenman 
> wrote:
>
>> Here's a suggestion for the docs:
>>
>> https://github.com/racket/racket/pull/2505
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-27 Thread Laurent
Wait, that means that in an interactive session, if you ever happen to
redefine `else', you can't use `case' anymore?

On Tue, Feb 26, 2019 at 5:03 AM Ben Greenman 
wrote:

> Here's a suggestion for the docs:
>
> https://github.com/racket/racket/pull/2505
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Ben Greenman
Here's a suggestion for the docs:

https://github.com/racket/racket/pull/2505

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Jon Zeppieri
Previously on this program...

https://lists.racket-lang.org/dev/archive/2013-May/thread.html
[racket-dev] else clauses: possible change to match?



On Mon, Feb 25, 2019 at 10:59 PM Greg Hendershott 
wrote:

> Yep, I also spent a non-zero number of years not even realizing "else"
> wasn't a magic literal for match. And then remembering to use _
> instead, as Sorawee suggested.
>
>
> I think this shows why it's usually better for syntax to use
> #:keywords instead of literals? If cond and case used #:else, this
> wouldn't be a problem.
>
> (Racket inherited those from Scheme. But we don't have to follow that
> example in our own, new macros.)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Greg Hendershott
Yep, I also spent a non-zero number of years not even realizing "else"
wasn't a magic literal for match. And then remembering to use _
instead, as Sorawee suggested.


I think this shows why it's usually better for syntax to use
#:keywords instead of literals? If cond and case used #:else, this
wouldn't be a problem.

(Racket inherited those from Scheme. But we don't have to follow that
example in our own, new macros.)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Robby Findler
I have been bitten by this one too, it is a bit pernicious. Perhaps we
can adjust the documentation to make more clear that `else` isn't
special in `match`?

Robby

On Mon, Feb 25, 2019 at 6:51 PM Sorawee Porncharoenwase
 wrote:
>
> I usually use _ for the otherwise case because I usually match on an 
> identifier, so I have an id to refer to the matched value already if I need 
> to. The only case I don’t use _ is when I compute something inside the match 
> and also need to use its result:
>
> (match (foo bar)
>   [... ...]
>   [result-of-foo-bar ...])
>
>
> On Mon, Feb 25, 2019 at 4:41 PM Shu-Hung You 
>  wrote:
>>
>> Ah!
>>
>> Thank you for pointing this out. I've always thought that `else' is
>> treated as a keyword in `match' just as what `cond' does. That
>> explains everything.
>>
>> On Mon, Feb 25, 2019 at 6:35 PM Sam Tobin-Hochstadt
>>  wrote:
>> >
>> > This is because 'case' expects a particular binding for 'else', but you 
>> > shadowed it with 'match', which does not treat 'else' differently than any 
>> > other identifier.
>> >
>> > Sam
>> >
>> > On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You 
>> >  wrote:
>> >>
>> >> When using a case expression with an else clause in inside a match
>> >> expression, the expander complains about case having a bad syntax.
>> >> However, the use of case expressions outside of match are fine. Is
>> >> there anyway to get around this?
>> >>
>> >> Currently, I just replace it with another match.
>> >>
>> >> #lang racket/base
>> >>
>> >> (require racket/match)
>> >>
>> >> (match 6
>> >>   [else
>> >>(case 5
>> >>  [else 7])])
>> >>
>> >> #|
>> >> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
>> >> in: (case 5 (else 7))
>> >>   #(78 4)
>> >> |#
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google Groups 
>> >> "Racket Users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send an 
>> >> email to racket-users+unsubscr...@googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Sorawee Porncharoenwase
I usually use _ for the otherwise case because I usually match on an
identifier, so I have an id to refer to the matched value already if I need
to. The only case I don’t use _ is when I compute something inside the
match and also need to use its result:

(match (foo bar)
  [... ...]
  [result-of-foo-bar ...])


On Mon, Feb 25, 2019 at 4:41 PM Shu-Hung You <
shu-hung@eecs.northwestern.edu> wrote:

> Ah!
>
> Thank you for pointing this out. I've always thought that `else' is
> treated as a keyword in `match' just as what `cond' does. That
> explains everything.
>
> On Mon, Feb 25, 2019 at 6:35 PM Sam Tobin-Hochstadt
>  wrote:
> >
> > This is because 'case' expects a particular binding for 'else', but you
> shadowed it with 'match', which does not treat 'else' differently than any
> other identifier.
> >
> > Sam
> >
> > On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You <
> shu-hung@eecs.northwestern.edu> wrote:
> >>
> >> When using a case expression with an else clause in inside a match
> >> expression, the expander complains about case having a bad syntax.
> >> However, the use of case expressions outside of match are fine. Is
> >> there anyway to get around this?
> >>
> >> Currently, I just replace it with another match.
> >>
> >> #lang racket/base
> >>
> >> (require racket/match)
> >>
> >> (match 6
> >>   [else
> >>(case 5
> >>  [else 7])])
> >>
> >> #|
> >> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
> >> in: (case 5 (else 7))
> >>   #(78 4)
> >> |#
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Shu-Hung You
Ah!

Thank you for pointing this out. I've always thought that `else' is
treated as a keyword in `match' just as what `cond' does. That
explains everything.

On Mon, Feb 25, 2019 at 6:35 PM Sam Tobin-Hochstadt
 wrote:
>
> This is because 'case' expects a particular binding for 'else', but you 
> shadowed it with 'match', which does not treat 'else' differently than any 
> other identifier.
>
> Sam
>
> On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You 
>  wrote:
>>
>> When using a case expression with an else clause in inside a match
>> expression, the expander complains about case having a bad syntax.
>> However, the use of case expressions outside of match are fine. Is
>> there anyway to get around this?
>>
>> Currently, I just replace it with another match.
>>
>> #lang racket/base
>>
>> (require racket/match)
>>
>> (match 6
>>   [else
>>(case 5
>>  [else 7])])
>>
>> #|
>> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
>> in: (case 5 (else 7))
>>   #(78 4)
>> |#
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Sam Tobin-Hochstadt
This is because 'case' expects a particular binding for 'else', but you
shadowed it with 'match', which does not treat 'else' differently than any
other identifier.

Sam

On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You <
shu-hung@eecs.northwestern.edu> wrote:

> When using a case expression with an else clause in inside a match
> expression, the expander complains about case having a bad syntax.
> However, the use of case expressions outside of match are fine. Is
> there anyway to get around this?
>
> Currently, I just replace it with another match.
>
> #lang racket/base
>
> (require racket/match)
>
> (match 6
>   [else
>(case 5
>  [else 7])])
>
> #|
> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
> in: (case 5 (else 7))
>   #(78 4)
> |#
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread 'John Clements' via Racket Users
I may be missing something obvious, here, but why are you using the name “else” 
to bind the result in the match clause? I usually use the name “other”, which 
might solve your problem.

John

> On Feb 25, 2019, at 4:32 PM, Shu-Hung You 
>  wrote:
> 
> When using a case expression with an else clause in inside a match
> expression, the expander complains about case having a bad syntax.
> However, the use of case expressions outside of match are fine. Is
> there anyway to get around this?
> 
> Currently, I just replace it with another match.
> 
> #lang racket/base
> 
> (require racket/match)
> 
> (match 6
>  [else
>   (case 5
> [else 7])])
> 
> #|
> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
> in: (case 5 (else 7))
>  #(78 4)
> |#
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Shu-Hung You
When using a case expression with an else clause in inside a match
expression, the expander complains about case having a bad syntax.
However, the use of case expressions outside of match are fine. Is
there anyway to get around this?

Currently, I just replace it with another match.

#lang racket/base

(require racket/match)

(match 6
  [else
   (case 5
 [else 7])])

#|
unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
in: (case 5 (else 7))
  #(78 4)
|#

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.