Discussion:
Type range in generic
(too old to reply)
Simon Jackson
2018-11-30 15:12:38 UTC
Permalink
GENERIC GHandle<T, R> = CLASS
PROTECTED
it: Array [R] of T;
FUNCTION readIt(p: R): T; VIRTUAL;
PROCEDURE WriteIt(p: R; what: T); VIRTUAL;
PUBLIC
PROPERTY gimmeIt[p: R] READ ReadIt WRITE Writeit; DEFAULT; (* does this
work? x.y -> x.it.y *)
END;

Error: Error in type definition just after R on line 3.
--
http://www.kring.co.uk
Sven Barth via fpc-devel
2018-12-02 09:00:20 UTC
Permalink
Am Sa., 1. Dez. 2018, 08:44 hat Simon Jackson <***@gmail.com>
geschrieben:

> GENERIC GHandle<T, R> = CLASS
> PROTECTED
> it: Array [R] of T;
> FUNCTION readIt(p: R): T; VIRTUAL;
> PROCEDURE WriteIt(p: R; what: T); VIRTUAL;
> PUBLIC
> PROPERTY gimmeIt[p: R] READ ReadIt WRITE Writeit; DEFAULT; (* does this
> work? x.y -> x.it.y *)
> END;
>
> Error: Error in type definition just after R on line 3.
>

Please report as a bug.

Regards,
Sven

>
Ryan Joseph
2018-12-02 09:19:35 UTC
Permalink
> On Dec 2, 2018, at 4:00 PM, Sven Barth via fpc-devel <fpc-***@lists.freepascal.org> wrote:
>
> Please report as a bug.

I don’t get a bug on this in the trunk version I’m using. Maybe it was fixed?

Regards,
Ryan Joseph

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http:/
Sven Barth via fpc-devel
2018-12-02 16:01:44 UTC
Permalink
Am So., 2. Dez. 2018, 10:50 hat Ryan Joseph <***@thealchemistguild.com>
geschrieben:

>
>
> > On Dec 2, 2018, at 4:00 PM, Sven Barth via fpc-devel <
> fpc-***@lists.freepascal.org> wrote:
> >
> > Please report as a bug.
>
> I don’t get a bug on this in the trunk version I’m using. Maybe it was
> fixed?
>

Could be, I didn't test yet. But even then it can be resolved with "no
change required". ;) (and be added as a test case)

Regards,
Sven

>
Simon Jackson
2018-12-02 23:33:02 UTC
Permalink
Just an idea.

Class variables. If generics are used, then the same code can be used for differing pointer types. (Classes) as long as a specifier on the "generic class variable" and no generic specialize or <> is in the

class generic x: TObject;

Can it be shared across all generics of a kind?

The code density in the cache would be good for all common generics.

https://kring.co.uk

________________________________
From: fpc-devel <fpc-devel-***@lists.freepascal.org> on behalf of Sven Barth via fpc-devel <fpc-***@lists.freepascal.org>
Sent: Sunday, December 2, 2018 4:01:44 PM
To: FPC developers' list
Cc: Sven Barth
Subject: Re: [fpc-devel] Type range in generic

Am So., 2. Dez. 2018, 10:50 hat Ryan Joseph <***@thealchemistguild.com<mailto:***@thealchemistguild.com>> geschrieben:


> On Dec 2, 2018, at 4:00 PM, Sven Barth via fpc-devel <fpc-***@lists.freepascal.org<mailto:fpc-***@lists.freepascal.org>> wrote:
>
> Please report as a bug.

I don’t get a bug on this in the trunk version I’m using. Maybe it was fixed?

Could be, I didn't test yet. But even then it can be resolved with "no change required". ;) (and be added as a test case)

Regards,
Sven
Ryan Joseph
2018-12-03 04:03:34 UTC
Permalink
> On Dec 3, 2018, at 6:33 AM, Simon Jackson <***@gmail.com> wrote:
>
> Just an idea.
>
> Class variables. If generics are used, then the same code can be used for differing pointer types. (Classes) as long as a specifier on the "generic class variable" and no generic specialize or <> is in the
>
> class generic x: TObject;
>
> Can it be shared across all generics of a kind?
>
> The code density in the cache would be good for all common generics.

I don’t get what this is trying to accomplish or how it’s used. Example?

Regards,
Ryan Joseph

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.fre
Sven Barth via fpc-devel
2018-12-03 07:05:48 UTC
Permalink
Am Mo., 3. Dez. 2018, 00:33 hat Simon Jackson <***@gmail.com>
geschrieben:

> Just an idea.
>
> Class variables. If generics are used, then the same code can be used for
> differing pointer types. (Classes) as long as a specifier on the "generic
> class variable" and no generic specialize or <> is in the
>
> class generic x: TObject;
>
> Can it be shared across all generics of a kind?
>
> The code density in the cache would be good for all common generics.
>

I don't see a use for such a feature.
What if one sets it as a descendant of one class, but another retrieves it
as a descendent of a completely different class? You'd have to use separate
storage locations then anyway and then you can simply use ordinary class
variables.

Regards,
Sven

>
Loading...