[fpc-devel] *** GMX Spamverdacht *** Re: Dangerous optimization in CASE..OF
Ozz Nixon
ozznixon at gmail.com
Sat Apr 14 14:42:57 CEST 2018
I understand the thread, however, in one of the ISO standards for Pascal, the keyword is, is defined for type not value. The example I gave is the only way I can see supporting is on non objects - because we are a typed language. That was my point, not arguing against, however, sharing a way I could see a value of it. Other than that, I am against...
Ozz
> On Apr 14, 2018, at 8:38 AM, Thorsten Engler <thorsten.engler at gmx.net> wrote:
>
> Eh, Ozz? Did you actually read this thread?
>
> It has nothing to do with the declared type of i. it compares the current value of i against the range of the specified type and will return true if the current value falls inside that range.
>
> 5 is TSubRange -> true
> 2000 is TSubRange -> false
>
> Also:
>
> case i as TSubRange of //exception if i < -5 or i > 5
>
>
>
>> -----Original Message-----
>> From: fpc-devel <fpc-devel-bounces at lists.freepascal.org> On Behalf
>> Of Ozz Nixon
>> Sent: Saturday, 14 April 2018 22:13
>> To: FPC developers' list <fpc-devel at lists.freepascal.org>
>> Subject: *** GMX Spamverdacht *** Re: [fpc-devel] Dangerous
>> optimization in CASE..OF
>>
>> I have to ask why?
>>
>> i is Int64 only, will always be int64 only, so all other
>> comparisons are always skipped.
>>
>> I could see this, inside a method with an untyped parameter:
>>
>> procedure doSomething(myvar;out success:boolean); Begin
>> {… your if is comparisons …}
>> end;
>>
>> This opens your method to be used for all types for param1.
>>
>> Ozz
>>
>>> On Apr 14, 2018, at 5:51 AM, Thorsten Engler
>> <thorsten.engler at gmx.net> wrote:
>>>
>>> I haven't checked out the changes you made to the compiler, so
>> you might have already covered this, but while you are at it, you
>> might want to just make this work for any ordinal type with a well-
>> defined upper/lower bound (any type for which High()/Low() can be
>> evaluated at compile time). So:
>>>
>>> type
>>> TSubRange=-5..5;
>>> TEnum=(One, Two);
>>>
>>> var
>>> i: Int64;
>>>
>>> begin
>>> if i is TSubRange then
>>> //...
>>> If i is TEnum then
>>> //...
>>> If i is SmallInt then
>>> //...
>>>
>>> (same with "as").
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: fpc-devel <fpc-devel-bounces at lists.freepascal.org> On
>> Behalf Of
>>>> Ondrej Pokorny
>>>> Sent: Saturday, 14 April 2018 19:03
>>>> To: fpc-devel at lists.freepascal.org
>>>> Subject: Re: [fpc-devel] Dangerous optimization in CASE..OF
>>>>
>>>> On 14.04.2018 10:39, Thorsten Engler wrote:
>>>>> How about following the same schema as with classes?
>>>>>
>>>>> If 1 is TMyEnum then
>>>>> //use hard cast here
>>>>
>>>> Yes, that is reasonable as well and it will be easier to
>> implement
>>>> than the TryIntToEnum/IntToEnum intrinsics for me.
>>>>
>>>> Ondrej
>>>> _______________________________________________
>>>> fpc-devel maillist - fpc-devel at lists.freepascal.org
>>>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>>
>>> _______________________________________________
>>> fpc-devel maillist - fpc-devel at lists.freepascal.org
>>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>
>> _______________________________________________
>> fpc-devel maillist - fpc-devel at lists.freepascal.org
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
More information about the fpc-devel
mailing list