[fpc-pascal] Interface syntax: Is possible don't use specialize in mode objfpc?

silvioprog silvioprog at gmail.com
Thu Jul 16 19:49:17 CEST 2015


On Thu, Jul 16, 2015 at 2:21 PM, Michael Van Canneyt <michael at freepascal.org
> wrote:

> On Thu, 16 Jul 2015, Marcos Douglas wrote:
>
>> On Thu, Jul 16, 2015 at 11:44 AM, Michael Van Canneyt
>> <michael at freepascal.org> wrote:
>>
>>>
>>>
>>> On Thu, 16 Jul 2015, Maciej Izak wrote:
>>>
>>>  sadly - no, only in Delphi mode. btw. this thing keep me away from
>>>> objfpc.
>>>>
>>>
>>>
>>> That seems like a very strange reason to me.
>>>
>>> The fact that you must type 1 word in certain places keeps you from
>>> using an
>>> otherwise useful mode ?
>>> This word is there for clarity, It is meant to help you, to make explicit
>>> you are in fact specializing a new type.
>>>
>>
>> Yes, but do you think this is more verbose unnecessarily? Because the
>> syntax TFoo<T> (I mean this "<>") show us that is a generic, don't?
>>
>> The Lazarus also has some troubles with the code completion using this:
>> TFoo = class(TInterfacedObject, specialize ICloneable<TFoo>)
>>
>
> Lazarus is not alone, even I have trouble with this :)
>
>
>> Sometimes the IDE shows an error in interface declaration, but compiles.
>> So, to not receive these errors I have to create a new type:
>>
>> TFoo = class; //forward
>>
>> IFooCloneable = specialize ICloneable<TFoo>;
>>
>> TFoo = class(TInterfacedObject, IFooCloneable)
>> //...
>> end;
>> ...making even more verbose.
>>
>
> Pascal is a verbose language. If you want terse, use C++ or something like
> it.
>
> The whole generics mess that Delphi made goes completely against the
> Pascal dictum that you must declare something before you can use it.
>
> To me, the above verbose construction makes absolute sense. It has been so
> since day 1:
>
> PRecord = ^TRecord;
> TRecord = record
>   a : integer;
>   next : PRecord;
> end;
>
> Michael.


IMHO this could be decided via poll, because several users around the world
are using FPC too. For example, in a polling, I would vote in less
keywords, e.g: [+1 vote for: "TFoo = class(TInterfacedObject,
ICloneable<TFoo>)" / "t.Add<LongInt>(2, 4);"] and [-1 vote for: "TFoo =
class(TInterfacedObject, specialize ICloneable<TFoo>)" / "t.specialize
Add<LongInt>(2, 4);"].

The more verbose a language becomes, and needs more keywords to do simple
things, the more chances it has to be depreciated.

I use other languages too, like Java (Android) and JS (front-end /
AngularJS), but here in our company we are testing and thinking about
migrating a lot of our online structure to Node.js, because it is very
productive and less burocratic. For while we are using a mix of Pascal
(XE8/FPC 3) and Node.js via proxy + websocket, but the trend is to use only
JS in front-end and back-end.

--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150716/7f9cb76e/attachment.html>


More information about the fpc-pascal mailing list