From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani
> The important point is: Previously, there were invariants such as
> (integerp x) =3D=3D (eq (type-of x) 'integer) or that prin1 would = only
> generate #s(hash-table ...) for actual hash tables.=C2=A0 Now these
> invariants are broken.
Every patch we install changes an "invariant" (except for cosmeti= c
patches, changes to the build system, ...).
So we can't take such an absolute position, if we want to keep
developing Emacs (including fixing bugs): we necessarily have to judge
which invariants are worthy of being preserved and which ones aren't.
E.g. if we ever get good support for bignums, we'll likely have to brea= k
your first invariant.
Also we have to distinguish between breaking an invariant and not
enforcing it.=C2=A0 I do consider an Elisp code which creates a record of type `integer` as a bug, but I don't think it's worth this particul= ar
effort to enforce it.
Even with your extra check the above two invariants won't always hold.<= br> I can trivially break the first one with some add-advice on type-of.
Should we add another check to prevent breaking the "invariant" i= n that
other way?=C2=A0 The second can be broken without even using an advice on `prin1` simply by creating a record of type (make-symbol "hash-table&q= uot;).
Should we also add yet another check to try and avoid this other way to
break your "invariant"?
> But there's a discontinuity between "invariant is guaranteed&= quot; and
> "invariant is almost always guaranteed": the latter is ident= ical to
> "invariant is not guaranteed at all".
In Elisp, the general rule is that thanks to the dynamic nature of the
language, there are precious few invariants which really always hold.
E.g. as soon as your "invariant" calls a function by name, you= 9;re
exposed to breakage via the advice mechanism.
So, in a sense, Elisp is a landmine just like C.
> Yes, absolutely.=C2=A0 I don't care whether it's rare or hypot= hetical, it breaks
> an invariant, and invariants must not be broken.
You might like to try Agda or Coq, but Elisp will inevitably disappoint
you in this area.