Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-10

Type helper now work with CodeTools?

22 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anthony Walter
to Anthony Walter

Well I found bugs with it which cause CodeTools will throw an access violations in the IDE.

bug 28860 <http://bugs.freepascal.org/view.php?id=28860> if a type helper in another unit has a property, the second attempt to use code insight throws an access violation
Screenshot: http://cache.getlazarus.org/images/lazarus-type-helper-error.png

bug 28861 <http://bugs.freepascal.org/view.php?id=28861> if a type helper exists for a literal value code insight throws an access violation Example: 'Hello'. // throws an access violation after the dot -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151015/de64b2d4/attachment-0001.html>

Reply by email

Ondrej Pokorny
to Anthony Walter
Anthony Walter wrote 12 lines
Well I found bugs with it which cause CodeTools will throw an access violations in the IDE. bug 28860 <http://bugs.freepascal.org/view.php?id=28860> if a type helper in another unit has a property, the second attempt to use code insight throws an access violation Screenshot: http://cache.getlazarus.org/images/lazarus-type-helper-error.png bug 28861 <http://bugs.freepascal.org/view.php?id=28861> if a type helper exists for a literal value code insight throws an access violation Example: 'Hello'. // throws an access violation after the dot

First version was from me: http://bugs.freepascal.org/view.php?id=28266 , Mattias fixed some bugs and extended it. Unfortunately, some regressions have occured with the time.

I think what you found should be regressions (IIRC it worked in the past). Can you check rev 49405 (the initial helper support) if the AV occur there as well?

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151016/24e62d81/attachment.html>

Reply by email

Mattias Gaertner
to Anthony Walter: Well I found bugs with it which cause CodeTools will throw an access violations in the…
Show quoted text 7 lines
Well I found bugs with it which cause CodeTools will throw an access violations in the IDE. bug 28860 <http://bugs.freepascal.org/view.php?id=28860> if a type helper in another unit has a property, the second attempt to use code insight throws an access violation Screenshot: http://cache.getlazarus.org/images/lazarus-type-helper-error.png

Fixed.

bug 28861 <http://bugs.freepascal.org/view.php?id=28861> if a type helper exists for a literal value code insight throws an access violation Example: 'Hello'. // throws an access violation after the dot

The 'Hello'. was not yet implemented. I it is now.

It still looks strange to me.

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
"Mattias Gaertner" wrote

helper

> exists for a literal value code insight throws an access violation > Example: 'Hello'. // throws an access violation after the dot The 'Hello'. was not yet implemented. I it is now.

Also for numbers and enums?

It still looks strange to me.

Well... It's a logical extension of the type helpers however (and Delphi compatible). The only critical part is that literal constants don't have a type per se and thus the chosen helper might be different :/ (e.g. an Int16 helper when one expected an Int32 one or so...)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151017/fef98fda/attachment.html>

Reply by email

Ondrej Pokorny
to Sven Barth
Sven Barth wrote 9 lines
Also for numbers and enums? > It still looks strange to me. Well... It's a logical extension of the type helpers however (and Delphi compatible). The only critical part is that literal constants don't have a type per se and thus the chosen helper might be different :/ (e.g. an Int16 helper when one expected an Int32 one or so...)

For numbers, IMO it is over-complicated... Code like 15.Power2;
seems strange to me as well.

But it is definitely needed for enums:

program project1;
{$mode delphi}
type
   TMyEnum = (eOne, eTwo, eThree);
   TMyEnumHelper = record helper for TMyEnum
   public
     class function One: TMyEnum; static;
   end;

{ TMyEnumHelper }

class function TMyEnumHelper.One: TMyEnum;
begin
   Result := eOne;
end;
var
   e: TMyEnum;
begin
   e.|
   TMyEnum.|;
end.

-> doesn't work for me. (I am not sure if it is a regression, though. I don't remember everything. Nevertheless, it should work.)

Ondrej

Reply by email

Michael Van Canneyt
to Sven Barth: helper Also for numbers and enums? Well... It's a logical extension of the type helpers…
Sven Barth wrote 16 lines
Am 16.10.2015 23:45 schrieb "Mattias Gaertner" : >> bug 28861 <http://bugs.freepascal.org/view.php?id=28861> if a type helper >> exists for a literal value code insight throws an access violation >> Example: 'Hello'. // throws an access violation after the dot > > The 'Hello'. was not yet implemented. I it is now. Also for numbers and enums? > It still looks strange to me. Well... It's a logical extension of the type helpers however (and Delphi compatible). The only critical part is that literal constants don't have a type per se and thus the chosen helper might be different :/ (e.g. an Int16 helper when one expected an Int32 one or so...)

Even strings. I'm implementing the Delphi 10 type helpers of sysutils, and you can run into pretty weird situations and error messages :/

Michael.

Reply by email

Mattias Gaertner
to Sven Barth: helper Also for numbers and enums? Well... It's a logical extension of the type helpers…
Show quoted text 9 lines
Am 16.10.2015 23:45 schrieb "Mattias Gaertner" : > > bug 28861 <http://bugs.freepascal.org/view.php?id=28861> if a type helper > > exists for a literal value code insight throws an access violation > > Example: 'Hello'. // throws an access violation after the dot > > The 'Hello'. was not yet implemented. I it is now. Also for numbers and enums?

longint.member works.
enum.member does not. Did that work Ondrej?

Show quoted text 6 lines
> It still looks strange to me. Well... It's a logical extension of the type helpers however (and Delphi compatible). The only critical part is that literal constants don't have a type per se and thus the chosen helper might be different :/ (e.g. an Int16 helper when one expected an Int32 one or so...)

Does the compiler support 3.member?

Mattias

Mattias

Reply by email

Anthony Walter
to Mattias Gaertner

A question, are type helpers limited to one per type? That is to say, if I write a "type MyStringHelper = record helper for string" and Michael adds a "type LazStringHelper = record helper for string" in SysUtils, will only one of them work when I have both units added to the my uses clauses of another unit?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/3ca09043/attachment.html>

Reply by email

Dmitry Boyarintsev
to Anthony Walter: A question, are type helpers limited to one per type? That is to say, if I write a "type…
Anthony Walter wrote 6 lines
A question, are type helpers limited to one per type? That is to say, if I write a "type MyStringHelper = record helper for string" and Michael adds a "type LazStringHelper = record helper for string" in SysUtils, will only one of them work when I have both units added to the my uses clauses of another unit?

Only one of them will work, but you can use helpers inheritance.

http://www.freepascal.org/docs-html/ref/refse57.html#x114-12400010.5

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/fe17b8e9/attachment.html>

Reply by email

Sven Barth
to Mattias Gaertner: On Sat, 17 Oct 2015 09:28:53 +0200 longint.member works. enum.member does not. Did that…
"Mattias Gaertner" wrote 7 lines
On Sat, 17 Oct 2015 09:28:53 +0200 Sven Barth wrote: > > It still looks strange to me. > > Well... It's a logical extension of the type helpers however (and Delphi > compatible). The only critical part is that literal constants don't

have a

> type per se and thus the chosen helper might be different :/ (e.g. an

Int16

> helper when one expected an Int32 one or so...) Does the compiler support 3.member?

Yes. I especially adjusted the compiler to handle this correctly (in light of floating point constants). Sidenote: the compiler also supports floating point numbers with an without "e" to have type helper method calls. "True" and "False" as well by the way.
Best take a look at the tests we have (tests/test/tthlp*.pp), especially tthlp4.pp which deals with constants. The follow up tests also deal with the different String types combined with mode switches.

Oh and there are also class methods that can be called on both the values as well as the type names, just like on classes and records (don't know whether the CodeTools support these for helpers yet).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/8361f7cb/attachment.html>

Reply by email

Sven Barth
to Dmitry Boyarintsev: Only one of them will work, but you can use helpers inheritance.…

Am 18.10.2015 16:24 schrieb "Dmitry Boyarintsev" <

Show quoted text 7 lines
: On Sun, Oct 18, 2015 at 10:11 AM, Anthony Walter wrote: > > A question, are type helpers limited to one per type? That is to say, if

I write a "type MyStringHelper = record helper for string" and Michael adds a "type LazStringHelper = record helper for string" in SysUtils, will only one of them work when I have both units added to the my uses clauses of another unit?

Show quoted text 5 lines
Only one of them will work, but you can use helpers inheritance. http://www.freepascal.org/docs-html/ref/refse57.html#x114-12400010.5

Currently there is this restriction, yes, but I do plan to add a modeswitch that will rectify that, I just need to plan how overload resolution should work.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/9cc140ca/attachment.html>

Reply by email

Mattias Gaertner
to Sven Barth: have a Int16 Yes. I especially adjusted the compiler to handle this correctly (in light…
Show quoted text 7 lines
[...] Yes. I especially adjusted the compiler to handle this correctly (in light of floating point constants). Sidenote: the compiler also supports floating point numbers with an without "e" to have type helper method calls. "True" and "False" as well by the way. Best take a look at the tests we have (tests/test/tthlp*.pp), especially tthlp4.pp which deals with constants.

Is this Delphi compatible?

Mattias

Reply by email

Sven Barth
to Mattias Gaertner: On Sun, 18 Oct 2015 17:06:08 +0200 That's boring. Dynamic packages are more fun. ;)…
"Mattias Gaertner" wrote 10 lines
On Sun, 18 Oct 2015 17:06:08 +0200 Sven Barth wrote: >[...] > > Only one of them will work, but you can use helpers inheritance. > > > > http://www.freepascal.org/docs-html/ref/refse57.html#x114-12400010.5 > > Currently there is this restriction, yes, but I do plan to add a

modeswitch

> that will rectify that, I just need to plan how overload resolution

should

> work. That's boring. Dynamic packages are more fun. ;)

I need some breather topics between all that hardcore generics and packages stuff :P

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/16b04e13/attachment-0001.html>

Reply by email

Sven Barth
to Mattias Gaertner: On Sun, 18 Oct 2015 17:03:33 +0200 Is this Delphi compatible? Mattias
"Mattias Gaertner" wrote 6 lines
On Sun, 18 Oct 2015 17:03:33 +0200 Sven Barth wrote: >[...] > Yes. I especially adjusted the compiler to handle this correctly (in

light

> of floating point constants). Sidenote: the compiler also supports

floating

Show quoted text 6 lines
> point numbers with an without "e" to have type helper method calls. > "True" and "False" as well by the way. > Best take a look at the tests we have (tests/test/tthlp*.pp), especially > tthlp4.pp which deals with constants. Is this Delphi compatible?

Aside from potential bugs or oversights it is.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/e1165322/attachment.html>

Reply by email

Anthony Walter
to Sven Barth: modeswitch should I need some breather topics between all that hardcore generics and…

Just to be clear, when we're talking about dynamic packages we mean being able to:

A) compile and install package into the IDE without rebuilding the entire IDE
and
B) load and unload pkg package files in apps while they're running and access new classes/objects and their RTTI?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/c339158b/attachment.html>

Reply by email

Michael Van Canneyt
to Anthony Walter
Anthony Walter wrote 8 lines
Just to be clear, when we're talking about dynamic packages we mean being able to: A) compile and install package into the IDE without rebuilding the entire IDE and B) load and unload pkg package files in apps while they're running and access new classes/objects and their RTTI?

Yes.

Michael.

Reply by email

Dmitry Boyarintsev
to Sven Barth: Am 18.10.2015 16:24 schrieb "Dmitry Boyarintsev" < I write a "type MyStringHelper =…
Sven Barth wrote 5 lines
Currently there is this restriction, yes, but I do plan to add a modeswitch that will rectify that, I just need to plan how overload resolution should work.

I'm sure it has been discussed already in other threads, but are you going to allow to explicitly specify the helper which method needs to be called (in case of the ambiguity) ?

i.e.
uses
..myhelpers, code.codebot, ..

TMyClassHelper(obj).AsString;
Cross.CodeBot.StringHelper(obj).AsString

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151018/2924169e/attachment.html>

Reply by email

Sven Barth
to Anthony Walter: Just to be clear, when we're talking about dynamic packages we mean being able to: A)…
"Anthony Walter" wrote
Just to be clear, when we're talking about dynamic packages we mean being

able to:

A) compile and install package into the IDE without rebuilding the entire

IDE

and B) load and unload pkg package files in apps while they're running and

access new classes/objects and their RTTI?

Yes to both. Though point A will additionally require quite some work in the IDE (which won't be my part, though I'll provide helpful information where possible ^^ ).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151019/16585b8f/attachment.html>

Reply by email