[racket] member et al.

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Nov 11 09:42:32 EST 2010

I agree with Mark. I often write ? versions of functions like member
in my code when I write it the first time to show the "predicate

Another important case is when you don't want internal values to
"escape" to the client because you forget that member/and/etc return
the thing, not #t.


On Thu, Nov 11, 2010 at 6:07 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> On Thu, Nov 11, 2010 at 12:21 AM, Mark Engelberg
> <mark.engelberg at gmail.com> wrote:
>> I could loosen the types of these Booleans to be Any, but then I'm not
>> really reflecting the "predicate intent" of these functions.
> This seems to be your primary issue.  But I don't see why it's a
> problem.  In particular, you were happy with the semantics of `member'
> in Racket before, but now that you want to write types or contracts,
> you're unhappy.  What were you writing down for the specification of
> these functions before?  For example:
> ;; Any -> ???
> (define (one-two-or-three? n)
>  (member n '(1 2 3)))
> What should we write for ??? here?  I think that's the central
> question, not anything for types or contracts.  Maybe you wrote Any
> here - then you should be fine with writing Any as a contract or a
> type.  Maybe you wrote TruthValue, or something like that - then you
> can do exactly the same with types or contracts; see `truth/c' in the
> documentation.
> Maybe you were writing 'Boolean' here before, and trusting that
> nothing bad would happen, even though your specification was
> incorrect. Now using contracts or types forces you to correct your
> specification, and you'd prefer to change your semantics instead.
> That's a reasonable argument to have, although I disagree.  But it
> isn't about types or contracts, it's about what the semantics of
> `member' should be.
> --
> sam th
> samth at ccs.neu.edu
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.