Domains 
Author Message
 Domains

Is this legal in Dylan?

Library A:
define generic f (x);
define class <t> (<object>) end class;
define sealed domain f (<t>);
define class <s> (<object>) end class;
define class <c> (<s>,<t>) end class;
define method f (x :: <c>) end method;

Library B:
define method f (x :: <s>) end method;

I note that the method in library B is never called when x is a <t>.

What if I replaced method f(<c>) (the last line in library A) with:

define method f (x :: <t>) end method;

...which precisely matches the sealed domain?

Actually, I think the answer has something to do with 'next-method'. But
it's an interesting example.

--
Ashley Yakeley, Seattle WA



Tue, 15 May 2001 03:00:00 GMT  
 Domains

Quote:

>Is this legal in Dylan?

   No.  ( although I imagine a few implementations will take it.)

Quote:

>Library A:
>define generic f (x);

 define open generic f (x);  

         would a be start. :-) Generics and classes are sealed by default.
         The examples in the DRM in the sealed domain section are biffed
         in this respect. All the generics are classes are sealed so
         the sealed domains are immaterial.

Quote:
>define sealed domain f (<t>);
....
>Library B:
>define method f (x :: <s>) end method;

>I note that the method in library B is never called when x is a <t>.

  Well it could be invoked with an object that is a <t>.   However, the first
  argument isn't being specialized on a <t> or one of its subclasses.  
  Neither is a new subclass of <t> being created.

  The sealed domain impacts assumptions that may have been while compiling
  code internal to Library A (where f presumably gets used).

  Sealing isn't going to buy you too much in Library A where the object in
  question is a <s> and you are about to invoke "f".  Even though the
  object may be a <c> no aggressive optimizations can be made ( other
  than splitting the code on a test for an instance of <c>. ).

--

Lyman S. Taylor           "Computers are too reliable to replace

                                Commander Nathan Spring, "Starcops"



Tue, 15 May 2001 03:00:00 GMT  
 Domains


Quote:
>Is this legal in Dylan?

>Library A:
>define generic f (x);
>define class <t> (<object>) end class;
>define sealed domain f (<t>);
>define class <s> (<object>) end class;
>define class <c> (<s>,<t>) end class;
>define method f (x :: <c>) end method;

>Library B:
>define method f (x :: <s>) end method;

No.  The method in library B is has a specializer which is not disjoint
from <t> due to the existance of <c>, so attempting to add this method
violates the "define sealed domain" from library A.

Quote:
>I note that the method in library B is never called when x is a <t>.

Doesn't matter.  See below.

Quote:
>What if I replaced method f(<c>) (the last line in library A) with:

>define method f (x :: <t>) end method;

>...which precisely matches the sealed domain?

Same answer.  <t> is trivially not disjoint from <t>.

Quote:
>Actually, I think the answer has something to do with 'next-method'. But
>it's an interesting example.

Correct.  Think of rules 1 & 2 for "define sealed domain" (DRM p.136) as
locking down the result of sorted-applicable-methods for concrete classes
within the domain.  Rule 3 keeps you from sneaking into the domain a new
concrete class with a different result for that function than would be
obtained by looking at the explicitly known set of classes which are
superclasses of that new class.

And yes, rule 3 is complex.  It seems to need to be so.  At least, all
attempts I know of to produce a less complex version of this rule have
been flawed, including (if I remember correctly) the version in the DIRM.



Wed, 16 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Time domain to frequency domain...and back again

2. convert time domain to frequency domain

3. public domain prolog for apollo domain

4. How to change the waveform graph from time domain to frequency domain?

5. how can frequency domain data be changed to time domain data?

6. "The domain refers to global non-reference domains"

7. Mind.rexx AI public domain

8. Public domain APL?

9. Public Domain Unix APL Interpreter

10. Public Domain APL for PC's

11. Public domain APL for the IBM PC

12. Conference on Domain-Specific Languages (DSL) - Call for Papersj

 

 
Powered by phpBB® Forum Software