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: Boris Kolar
Subject: Re: [DotGNU]private inheritence syntax (was Re: C@)
Date: Fri, 16 Aug 2002 10:41:38 +0200

> 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 drawback of this is that it may replace too many words, not just what's 
intended. Putting syntax issues besides, the idea was to
allow programmer to modify behaviour (including inheritance) of existing class, 
without modifying it's source. For example, there
may be two libraries for scanner driver, each with it's own definition of 
"Scanner":

library A:
  public class Fujistu1234Scanner: AbstractScanner {
    ...
  }

library B:
  public class Cannon1234Scanner: Scanner {
    ...
  }

... where AbstractScanner and Scanner are similar, but not derived from the 
same class. Now, as a developer using both libraries,
i'd like to make these libraries compatible with each other. If i modify one of 
the libraries, i'll have to do all modifications
again when new version of the library is released, so i'd like to change the 
class without source modification.


----- Original Message -----
From: "Peter Minten" <address@hidden>
To: "Boris Kolar" <address@hidden>
Cc: "S11001001" <address@hidden>; "DotGNU Mailing List" <address@hidden>
Sent: 15. August 2002 16:18
Subject: Re: [DotGNU]private inheritence syntax (was Re: C@)


> 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
>
>
> _______________________________________________
> Developers mailing list
> address@hidden
> http://www.dotgnu.org/mailman/listinfo/developers
>



reply via email to

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