help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is booleanp defined this way?


From: Rusi
Subject: Re: Why is booleanp defined this way?
Date: Fri, 17 Apr 2015 22:00:34 -0700 (PDT)
User-agent: G2/1.0

On Saturday, April 18, 2015 at 9:47:41 AM UTC+5:30, Pascal J. Bourguignon wrote:
> Rusi  writes:
> 
> >> I never used `booleanp' and I never experienced that
> >> the boolean built-in type was missing from my
> >> "ontology".
> >
> > If you how to write (and grok) an 'if' you have boolean in your
> > ontology.
> 
> Not exactly.  There's something magical occuring in if.
> 
> if takes an expression that is _used_ _as_ a condition.
> 
> Often, that expression is a boolean,  but that depends on the
> language. For example, in C, the expression is any expression, and it is
> tested against 0 to define the (negation of the) condition.
> 
> You could define a language without ANY predefined types, and then you
> would have to declare the mapping between the values of some
> user-defined type and the condition used by any "conditional"
> instruction or operator.
> 
>     (deftype booleen () `(member vrai faux))
> 
>     (declare-if-conditions :then (eql vrai)
>                            :else (eql faux))
> 
>     (if t 'yes 'no) --> #<error t is not a valid condition value>
>     (if 'vrai 'yes 'no) --> yes
> 
> 
>     (declare-if-conditions :else (function zerop))
> 
>     (if 'vrai 'yes 'no)  --> #<error vrai is not a valid condition value>
>     (let ((a 2)) (if (- a 2) 'yes 'no)) --> yes
> 
> (Of course, it is not too useful to have such things in lisp, we're
> happy with generalized booleans, but once upon a time, I fancied a
> language with no predefined types, as a way to achieve better
> portability. Like C is "good" for I/O by reason of having no I/O
> operator (compared to eg. Pascal), a typeless static language would be
> good for portability, because it would have no implicit dependence on
> the processor data types such as int32 or int64; you'd declare your own
> integer ranges and the compilers would ensure it works everywhere.
> 
>   (deftype my-int () `(integer -20 1000000))
>   (let ((a 0))
>     (declare (type (my-int a)))
>     (incf a))
> 
> But again, for lisp or any other non-statically typed programming
> language, this is mute.

<irony>
I know very little CL so dont really get what you are saying.
Can you say it in scheme?
(ironical on this thread!)
</irony>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]