[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Question about Generic Aspects
|
Hi Alex,
[code]
aspect AddStudents<T> {
[...]
declare parents: T implements HasStudents;
[...]
}
Yes, it should of course be T implements HasStudents --- my mistake.
afaik java generics are different that C++ templates (where new types
are created). Foo extends AddStudents<T> and Bar extends AddStudents<T>
should work (at least this is my understand).
Yes, Java generics are certainly different from C++ templates. However,
the question is whether generic aspects are or not, since the
documentation seems to imply there is a fundamental departure from
normal generics ...
Right, so the case that I'm really interested is the following:
> public aspect Assoc<X,Y> {
> interface HasXs {}
> interface HasYs {}
>
> declare parents : Y implements HasXs;
> declare parents : X implements HasYs;
>
> public List<Y> HasYs.ys = new ArrayList<Y>();
> public List<X> HasXs.xs = new ArrayList<X>();
> }
I don't think this may result in a name clash, but rather in a
compilation error: you will have a Foo.ys field having 2 different
types: List<Bar> and List<Car>.
Right --- that's what I meant!
Cheers,
Dave
:alex |.::the_mindstorm::.|
Cheers,
Dave
On 09/09/05, David Pearce <david.pearce@xxxxxxxxxxxxx> wrote:
Hi all,
I have been reading the Aspectj 1.5 note book and have a question about
generic aspects, which I'm hoping someone can help me with. The
documentation says:
"The type parameter variables from a generic aspect declaration may be
used in place of a type within any member of the aspect, except for
within inter-type declarations."
But, it seems that the example goes on to do just this. Namely:
> public abstract aspect ParentChildRelationship<Parent,Child> {
> ...
> declare parents: Parent implements ParentHasChildren<Child>;
> ...
> }
So, I'm wondering whether I just missed something or, if not, which way
around it should be.
Thanks,
David J. Pearce
--
Lecturer in Computer Science,
School of Mathematics, Statistics and Computer Science,
Victoria University of Wellington,
PO Box 600,
Wellington,
New Zealand.
Office: Cotton 231
Telephone: +64 4 463 5833
URL: http://www.mcs.vuw.ac.nz/~djp
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
--
Lecturer in Computer Science,
School of Mathematics, Statistics and Computer Science,
Victoria University of Wellington,
PO Box 600,
Wellington,
New Zealand.
Office: Cotton 231
Telephone: +64 4 463 5833
URL: http://www.mcs.vuw.ac.nz/~djp