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

>
>
> On Tuesday, November 1, 2016, David Storrs <david.sto...@gmail.com> wrote:
>
>>
>>
>> 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.
>>
>
> It is a syntax error.
>

Absolutely, but that's not what the message says.  :>



> 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."
>>
>
> The optional argument list is optional actually. This is the root of the
> problem: it thinks that the () was your range contract and then gets
> confused that there is still more coming.
>

Maybe it shouldn't be optional, then?  I'm not sure that saving two
characters is worth the confusion that results from getting it wrong.  I
realize that making it optional without warning would break a lot of old
code...maybe skipping the optional argument could be deprecated and
eventually it could be rendered mandatory in a future release?



>
>
>
>> 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.
>>
>>
> I could say "only the rest argument contract and the result contract can
> follow #:rest". Would that wording have helped?
>

Yep, that would have been perfect.



>
> Robby
>
>
>> 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.
>>
> --
> 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