On 14/04/2019 00:01, Sven Barth via fpc-pascal wrote:

Well, there is Oxygene's concept of Class Contracts (see
https://docs.elementscompiler.com/Concepts/ClassContracts/ ), so if
anything in that direction would be done I'd be inclined towards their
syntax (and I've played with the idea to implement this in FPC for quite
some time already).

Though of course it wouldn't necessarily solve the point of knowing
whether one may pass Nil or not, cause especially in compiled code you
can't look at the source. So the compiler would need to store the
conditions in the PPU as well, so that the IDE could present them as
part of the tooltip even if no source is available...

Well it needs to be in the ppu anyway, because even without source, an object can be inherited from.

And the inherited method must fulfil some of the conditions
- It can't accept less than its base (requirements can be looser, but not tighter) - It must fulfil the "ensure"s, or be even stricter. (as that would still fulfil them)

Also being in the ppu, would allow compile time errors, when passing violating constants.

There are a few things about the oxygen syntax.

1) require is outside the begin..end, but ensure is inside.

2) As the nature of those conditions can be inherited, they are more to be thought of as declaration, than implementation. That would call for them to be in the interface. Though of course that messes up the interface....


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to