[bitc-dev] Forward and extern declarations

Swaroop Sridhar swaroop.sridhar at gmail.com
Sun Jul 17 12:31:31 EDT 2005


Jonathan S. Shapiro wrote:
> 
> Option 1: DEF
> 
>   (def (list 'a) :ref) ; list is an opaque reference type
>   (def a : int32) ; a is an externally defined variable
> 
> Option 2: Variants on current definition syntax:
> 
>   (defunion (list 'a) :ref)  ; declare opaque reference type
>   (defunion (list 'a) nil (cons 'a (list 'a))) ; definition
> 
>   (define a : int32) ; extern declaration
>   (define a 1) ; definition
> 
> Option 3:
> Same as option 2, but the declaring forms end with '*', thus:
> 
>   (defunion* (list 'a) : ref)
> 
> I am provisionally inclined to go with DEF, but I would appreciate
> input.
>

I am not super-impressed with option 2/3 because:
i) It is less opaque -- it reveals whether a type is a union/structure.
ii) What about type names created by deftype?
iii) What about types created using fixint/ieeefloat type constructors?

> 
> MarkM and I also considered EXTERN and FORWARD, but neither quite works
> out well.
>

Is this because 'extern' is somewhat odd within the provider? Otherwise, 
I thought extern (or defextern) was indicative of the behavior of these 
declarations.


 >   (def (list 'a) :ref) ; list is an opaque reference type
 >   (def a : int32) ; a is an externally defined variable

I think these two forms are insufficient for purposes of custom opaque 
declarations.

For example:

(deftype i64 (fixint 32 32 #t))
(defunion ilist:ref Nil (Cons i64 ilist))

Now, if I want to expose the shape of ilist but NOT i64, there is NO way 
of doing it.

I cannot write:
(declare i64:ref) because it is NOT a reference type.

So we may have to re-introduce
    (def (list 'a) :val) ; list is an opaque value type

with the condition that the type is incomplete, and only references can 
be taken to it.

Swaroop.


More information about the bitc-dev mailing list