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

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

Re: why are there [v e c t o r s] in Lisp?


From: Emanuel Berg
Subject: Re: why are there [v e c t o r s] in Lisp?
Date: Sun, 18 Oct 2015 14:32:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> Because the presence of a data type in a language is
> unrelated to the presence of a syntax for literal
> objects of that type. ...
>
> So all the combinations are possible, which shows
> that having a literal syntax for objects and having
> types in a language are two totally
> unrelated things.

They are two different things but they are not
unrelated. If a language offers features A, B, and C,
then it should come in with a syntax a, b, and c to
facilitate the usage of them features.

> Type inference can still be useful in a lisp
> compiler, since it allows to produce code that is
> a little more efficient: you can avoid generating
> type dispatches and type checks in expressions using
> a variable, when you can infer that this variable
> will always hold values of a certain type.
>
> For inference, writing
>
>     (let ((a (vector 1 2 3))) (aref a 2))
>
>     (let ((a [1 2 3])) (aref a 2))
>
> have the exact same effect: in both case the
> compiler can infer that a is always bound to
> a vector of 3 elements, and therefore it can avoid
> testing whether 2 is bigger or smaller than the size
> of the vector, or that the value bound to a is
> indeed a vector before calling aref.

Inference can be based on the methods used to interact
with the object of the variable. For example the
predicates. If there is an `if' form with a predicate
test for a string (`stringp') and then an `error' if
the variable doesn't hold the string, depending on the
context and the sophistication of the inference
mechanism, it can be deducted the function should be
used with a string as value for a particular argument.
But again this is nothing I ever yearned for...

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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