On Tue, Nov 1, 2016 at 12:58 PM, Robby Findler <ro...@eecs.northwestern.edu>
wrote:

> I wish I could see how to make a better error message for this input,
> but I'm not seeing it. Do you?
>
> Robby
>
>
With this function:

(define/contract (register-functions . func-list)
     (->* () #:rest (listof procedure?) () any)

I got this message:

lib/test.rkt:56:5: ->*: expected the end of the contract
  at: (any)
  in: (->* () #:rest (listof procedure?) () any)


I can see a couple of possible alternatives:

1) Call it a syntax error.  That tells me that I've typed something wrong,
as opposed to there being something I don't know about the semantics of
contracts.

2) Have the compiler accept it, and optionally issue a warning.  These
could all be equivalent:

(->* () () #:rest ... result)
(->* () #:rest ... () result)
(->* #:rest ... () () result)

That would accord well with the general philosophy of "keywords can come in
any order and be freely mixed with positional arguments".

These might or might not still be errors, depending on how you look at it:

(->* #:rest ... () result)
(->* () #:rest ... result)

If it's an error, the message I would suggest is:  "Invalid contract.  ->*
requires both mandatory and optional argument lists, even if they are null."

I think this works -- only one thing can follow the #:rest keyword, right?
If so, it shouldn't be ambiguous what is referring to what.

Dave

On Tue, Nov 1, 2016 at 11:50 AM, David Storrs <david.sto...@gmail.com>
> wrote:
> > Aha.  It's always the simple things that get you.  Thanks, Alexis.
> >
> > On Tue, Nov 1, 2016 at 12:30 PM, Alexis King <lexi.lam...@gmail.com>
> wrote:
> >>
> >> You have the order wrong for ->*. The #:rest option should come
> >> after the positional argument contracts, just before the return
> >> contract. Since this function has no positional optional arguments,
> >> you can either omit the optional positional argument contracts
> >> entirely:
> >>
> >>     (->* () #:rest (listof procedure?) any)
> >>
> >> …or you can include it, before #:rest:
> >>
> >>     (->* () () #:rest (listof procedure?) any)
> >>
> >> > On Nov 1, 2016, at 9:18 AM, David Storrs <david.sto...@gmail.com>
> wrote:
> >> >
> >> > What would the correct contract for this function be?
> >> >
> >> > (define/contract (register-functions . func-list)
> >> >    (->* () #:rest (listof procedure?) () any)  ;; this is wrong
> >> >
> >> >    (for ((f func-list)) ...do something...))
> >> >
> >> >
> >> > I've read through the docs below and it doesn't make clear how to do
> it.
> >> >
> >> > https://docs.racket-lang.org/guide/contracts-general-functions.html
> >> > https://docs.racket-lang.org/reference/function-contracts.html
> >>
> >> --
> >> 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.

Reply via email to