Type-checking and defstruct 
Author Message
 Type-checking and defstruct

Following previous discussions on the net and with the FP people here, it
seems more clear that the analogue for type-language is with function-
definition and not with pattern-matching. Thus my "All" construct should be
seen as analogous to "procedure".  So I agree with Steve's suggestion of

   List(a)

or for that matter list(a) --- capitalisation is merely a convention, but
would argue against the ? and ?? forms. To extend the discussion to
data-types.

Consider the SML declaration:

    datatype 'a Tree = Node of 'a Tree* 'a Tree | Tip of 'a

how should something like this be treated in POP? I would unbundle it as

    Tree(a) = Node(a) + Tip(a)

or alternatively, and within  declare....enddeclare brackets

    define Tree(a); Node(a) + Tip(a)
    enddefine;

That is the second-order definitions may have the same form as the existing
first-order definitions.

And the second part of the definition is

    defstruct Node(a) = {left:Tree(a),right:Tree(a)}

If the -defstruct- is omitted, then the declaration is -abstract-, i.e. no
data-key and associated first-order functions are created. In either case
the following declarations are made:

    consNode : All a; Tree(a)*Tree(a) -> Node(a)
    destNode : All a; Node(a)-> Tree(a)*Tree(a)
    isNode   ? All a; Node(a)
    left     : All a; Node(a) -> Tree(a)
    right    : All a; Node(a) -> Tree(a)

Robin.



Tue, 14 May 1996 22:35:48 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Mutually Referential DEFSTRUCT Slot Types: How?

2. algorithm for type checking recursive types

3. type checking recursive types

4. type-checking / type() function

5. A Type checking/reconstruction procedure for Typed-Prolog

6. Dynamic vs. static type checking

7. File type checking in AWK - Can I do it

8. type check and dynamic binding

9. Compile time Type checking

10. About speed difference between ploymorphic call and explicit type checks

11. Strong type checking...

12. Type Checking-Please Read Urgent

 

 
Powered by phpBB® Forum Software