dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]private inheritence syntax (was Re: C@)


From: Peter Minten
Subject: Re: [DotGNU]private inheritence syntax (was Re: C@)
Date: Thu, 15 Aug 2002 16:18:16 +0200

Boris Kolar wrote:
> 
> > public class Foo : private PrivateClass1, PublicParent, PublicInterface,
> > private PrivateClass2 { /* ... */ };
> 
> I like that one too!

It will be in the spec, with the option of naming public parents explictely
as 'public' to make code more readable.
 
> If we have private inheritance, why not also "class" inheritance (inheritance 
> of type without methods)? True multiple inheritance would also be nice. It's 
> possible to avoid ambiguity problems if compiler forces you to resolve them 
> at compile time.
> 
> Like:
>   public class Foo: private PrivateClass1, 
           PublicParent1, PublicParent2, class SubType1 {
                                         ^^^^^ syntax error
:-)                       
>     PublicParent1.Name() = FooName(); // resolve ambuguity
>     PublicParent2.Name() = FooName(); // resolve ambuguity

More something like 'use this.Name() = PublicParent1.Name();'. The 'use' keyword
makes it easier for the compiler to recognize this special statement.

I'll put this in (hmm, multiple inheritance, interfaces, mixins, this language
is going to offer many options to do something :-).
 
> Inheritance by delegation would also be usefull:
>   public class Foo: Parent {
>     Parent = Bar();
>     private Parent Bar() { ... }
>   }

 
> For example, one might write a perfect class for scanner:
>   public class Cannon1234Scanner: Scanner {
>     ...
>   }
> ... and then remember, that Scanner is actually a special case of 
> ImageAcquisitionDevice:
>   public class extension Cannon1234Scanner: ImageAcquisitionDevice {
>     ...
>   }
> or something like that... "extension" keyword indicates that this class 
> definition redefines (extends) original Scanner1234Scanner and does not 
> define 
> a new class.

Let's do it another more way that requires less keywords (which saves
me work implementing the compiler :-). What you want here is that a certain
string is substituted. I believe this is best done by a more global 
substitution 
function, like this:

substitute "public class Cannon1234Scanner: %%Scanner%%",
"ImageAcquisitionDevice";

Since the '%%' character sequence is invalid in any C@ source file it can be
safely used as a delimiter for the area that should be replaced. Combine this
function with wildcards and you will get a nice allround function for various
tasks. 

The wildcards are: 
*        One word.
**       Multiple words with points in it if the previous char is a point and 
         else with spaces and chars in it.
$        One char.

The * and ** wildcards are replaced with #*# and #**# for programs with unsafe
code in it. For example the following pattern can be used: 
"* ba$ (System.Net.**, **)" 
This matches functions bar, baz, etc with any return type and with a first
argument in the System.Net namespace and zero or more arguments of any type as
the second to infinite arguments.

Greetings,

Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]