Re: [fpc-pascal] Chaining method calls

2020-03-25 Thread George Bakhtadze via fpc-pascal
Hi.

You can have such ID if you will use generics:

{$mode Delphi}
type
  TBase = class
  public
function AndThis: T;
  end;

function TBase.AndThis: T;
begin
  result := self as T;
end;

type
  TMyClass = class;
  TMyClass = class (TBase)
  end;

var
  c: TMyClass;
begin
  c := TMyClass.Create.AndThis;
  writeln(c.classname);
end.

Don't know how to write it with objfpc style generics but I believe it's 
possible.


24.03.2020, 16:55, "Ryan Joseph via fpc-pascal" 
:
> True, but then we're stuck in a typecasting game where I need to cast "c" 
> back to TMyClass. :) I probably brought this up years ago and forgot but 
> Objective-C has an "id" type which is "can assign to any class type". It 
> seems like something that would be standard for OOP but I don't recall ever 
> seeing it in Pascal or C++.

---
Best regards, George
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread wkitty42

On 3/24/20 6:58 PM, Sven Barth via fpc-pascal wrote:

wkitt...@windstream.net schrieb am Di., 24. März 2020, 18:37:


you should figure out why typed constants are not being allowed/used
in your setup...


Typed constants can not be used to initialize constants.



hummm... ok, so how to you get a constant to be a byte and storing 7 for the 
decimal value?


or are you saying that you cannot use a typed constant in the init of another 
(typed) constant?





--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list where it belongs!*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread Sven Barth via fpc-pascal
 schrieb am Mi., 25. März 2020, 18:47:

> On 3/24/20 6:58 PM, Sven Barth via fpc-pascal wrote:
> > wkitt...@windstream.net schrieb am Di., 24. März 2020, 18:37:
> >
> >> you should figure out why typed constants are not being allowed/used
> >> in your setup...
> >
> > Typed constants can not be used to initialize constants.
>
>
> hummm... ok, so how to you get a constant to be a byte and storing 7 for
> the
> decimal value?
>

The compiler normally uses the smallest possible type that can represent
the value. You can force it however by using e.g.

const
  MyConst = Word(42);


> or are you saying that you cannot use a typed constant in the init of
> another
> (typed) constant?
>

Correct.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread Howard Page-Clark via fpc-pascal

On 25/03/2020 17:46, wkitt...@windstream.net wrote:

On 3/24/20 6:58 PM, Sven Barth via fpc-pascal wrote:

wkitt...@windstream.net schrieb am Di., 24. März 2020, 18:37:


you should figure out why typed constants are not being allowed/used
in your setup...


Typed constants can not be used to initialize constants.



hummm... ok, so how to you get a constant to be a byte and storing 7 
for the decimal value?


or are you saying that you cannot use a typed constant in the init of 
another (typed) constant



Try

const
  seven = Byte(7);

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread wkitty42

On 3/25/20 2:17 PM, Sven Barth via fpc-pascal wrote:

wkitt...@windstream.net schrieb am Mi., 25. März 2020, 18:47:


hummm... ok, so how to you get a constant to be a byte and storing 7 for the
decimal value?



The compiler normally uses the smallest possible type that can represent the 
value. You can force it however by using e.g.


const
   MyConst = Word(42);



ok... so in the situation this thread is covering:

const
  foldhiddenbit = byte(7);
  foldhiddenmask = byte(1 shl foldhiddenbit);
  currentfoldhiddenbit = byte(6);
  currentfoldhiddenmask = byte(1 shl currentfoldhiddenbit);
  foldlevelmask = byte(not (foldhiddenmask or currentfoldhiddenmask));

is the way to do it?


or are you saying that you cannot use a typed constant in the init of another
(typed) constant?


Correct.



strange...

[wargames] seems like the winning move is to not play the game. [/wargames] LUL


--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list where it belongs!*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread Bart via fpc-pascal
On Wed, Mar 25, 2020 at 7:48 PM  wrote:

> [wargames] seems like the winning move is to not play the game. [/wargames] 
> LUL

LUL ??
What does that stand for?

Better not say that to someone who speaks Dutch (like me) ;-))

-- 
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread wkitty42

On 3/25/20 5:06 PM, Bart via fpc-pascal wrote:

On Wed, Mar 25, 2020 at 7:48 PM  wrote:


[wargames] seems like the winning move is to not play the game. [/wargames] LUL


LUL ??
What does that stand for?


it is the LOL emoticon with a beard... i've gotten to where i use it all the 
time instead of plain old lol... especially since i am bearded these days ;)



Better not say that to someone who speaks Dutch (like me) ;-))


what? you don't like laughing bearded guys?

https://knowyourmeme.com/memes/lul



--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list where it belongs!*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread Sven Barth via fpc-pascal
 schrieb am Mi., 25. März 2020, 19:48:

> On 3/25/20 2:17 PM, Sven Barth via fpc-pascal wrote:
> > wkitt...@windstream.net schrieb am Mi., 25. März 2020, 18:47:
> >
> >> hummm... ok, so how to you get a constant to be a byte and storing 7
> for the
> >> decimal value?
> >
> >
> > The compiler normally uses the smallest possible type that can represent
> the
> > value. You can force it however by using e.g.
> >
> > const
> >MyConst = Word(42);
>
>
> ok... so in the situation this thread is covering:
>
> const
>foldhiddenbit = byte(7);
>foldhiddenmask = byte(1 shl foldhiddenbit);
>currentfoldhiddenbit = byte(6);
>currentfoldhiddenmask = byte(1 shl currentfoldhiddenbit);
>foldlevelmask = byte(not (foldhiddenmask or currentfoldhiddenmask));
>
> is the way to do it?
>

In theory, yes, but for some reason the "not" upsets this. I have yet to
investigate why though and whether this is by design.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range check error warning.

2020-03-25 Thread Bart via fpc-pascal
On Wed, Mar 25, 2020 at 10:30 PM  wrote:

> what? you don't like laughing bearded guys?

LUL means penis (and I'm putting it nicely here) in Dutch.
Google translate translates it as either asshole (anatomically rahter
incorrect), cock, or prick.


-- 
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal