Abstraction Power


I appreciate seeing some discussion of types on the types list (!),
and mostly agree with what you say about safety. However, there seems
to be some crossed wires between you and Jon R in your discussion of

Jon claimed, following Reynolds, that types enable abstraction (as well as
being about catching errors early), to which you responded with
> As for abstraction, I claim that using a generative facility for structure
> definition I can enforce the same abstraction constraints w/o syntactic
> types (all programs run, safely) that you can enforce with types (some
> programs get rejected, the others run safely).

and later some stack code using advanced features of an advanced
Scheme.  There are two relevant points.

First, Jon never claimed that types were the *only* way to enforce
data abstraction. In fact, Reynolds had already argued convincingly in
1975 that types and procedures (objects) give you are two different
ways to implement data abstractions, each of which has limitations and
advantages that the other lacks. The paper is
   User-defined types and procedural data structures as complementary
approaches to data abstraction.  The claim is that user-defined types
provide centralized representations, which are happy with binary
operations while being difficult to extend, while procedural data
structures (objects) are easier to extend while providing
decentralized representations that are limited as regards binary
operations.  For my money, no one has yet found something that
combines the advantages of the procedural and type approaches, without
combininng their limitations.  It appears to me that you and Jon are
both right, and that your counter-argument does not negate his point
about abstraction.

Second, I was confused by your appeal to newfangled Scheme
facilities. That is, you claim that "using a generative facility for
structure definition I can enforce the same abstraction
constraints...", but isn't data abstraction already possible in plain
old Scheme?  E.g., the two definitions of a "counter object" below
must be equivalent, and you could do the same thing for stacks. So,
does this not show your conjecture
> I conjecture that the two features are necessary to make
>  Scheme's data representations abstract but I don't have a proof that
>  Scheme by itself can't do it.]
false? I'm not trying to be insulting here, as I expect you may know
a thing or two about Scheme: but maybe you can point out
if I have a misunderstanding.

But to sum up my point of view:
 (i) Types *do* provide for (enforced) data abstraction
 (ii) they are not the *only* way to do it (but no convincing "best" or most
general method has emerged)

best wishes,  Peter


;; counter with positive representation
(define counter
  (let ((state 0))
    (lambda (message)
       (cond ((eq? message 'inc) (set! state (+ state 1)))
             ((eq? message 'val) state)

;; counter with negative representation.
(define counter
  (let ((state 0))
    (lambda (message)
       (cond ((eq? message 'inc) (set! state (- state 1)))
             ((eq? message 'val) (- state))