[fpc-devel] Re: [fpc-l] type discussion

listmember listmember at letterboxes.org
Fri Jun 3 13:12:29 CEST 2005


Marc Weustink wrote:

>>>>-- Class Contracts
>>>>I like the 'require/ensure' aproach.
>>>>
>>>>It makes the code more robust and more debuggable, IMHO
>>>
>>>I think the checks you can do there are to limited. I also wonder what
>>>will happen if a require isn't met. Personally I don't want
>>>exeption in my released app.
>>
>>No, these are assertions not as exceptions.
> 
> OK, what to do if an invalid input is met ? Continue ? Skip ? Abort ?
> IMO you still need some code which takes proper action

You have a point here. That, I suppose could be handled through
runtime options. But, a construct something like

require
  [...]
otherwise
  [...]
end;

ensure
  [...]
otherwise
  [...]
end;

would be needed.

>>>>-- Generics
>>>>I am not sure if Generics could be done in FPC.
>>>
>>>There were some discussions about it here and AFAIK some are trying to
>>>implement.
>>
>>Any links?
> 
> http://www.freepascal.org/wiki/index.php/Generics

Thanks.

>>>>-- Virtual Properties and Events
>>>
>>>The examples given there are not very different of what is
>>>possible now.
>>>Make SetWith virtual and you have almost the same.
>>>
>>>What however would be nice is if you could override the getter
>>>or setter.
>>>Something like
>>>property Width write MySetWidth
>>
>>I think you missed a few things here.
>>
>>type
>>  TMyClass = class
>>    ...
>>    property Width: integer read write; virtual; abstract;
>>  end;
>>
>>As you can see, getters and setters are not in the picture
>>at all. Which means, you have all the freedom you want in
>>the derived class.
> 
> Which is allmost the same as a virtual abstract Getter and Setter (almost,
> read/write from a field isn't covered)
> 
> 
>>Plus, I like the idea that I could have a base class
>>with read-only property that can not be overriden to be
>>read-write later.
>>
>>    property Width: integer read; virtual; abstract;
> 
> That makes some sense (but it would be incompatible with existing code)

Why would it. Existing code does not have virtual properties.





More information about the fpc-devel mailing list