xsharp.eu • Strong typed init, no compiler error on missing parameters?
Page 1 of 1

Strong typed init, no compiler error on missing parameters?

Posted: Thu Dec 16, 2021 1:30 pm
by ic2
Why does this not generate a compiler error in VO:

oFTP := FtpAX{cFtp, dwPoort, dwTimeout, cRemoteDir, cUser, cPW, TRUE, FALSE, FALSE, FALSE,(one parameter false missing)}

METHOD Init(cHost AS STRING, dwFTPport AS DWORD, dwFTPtimeout AS DWORD, cRDir AS STRING, cUser AS STRING, cPass AS STRING, lPassive AS LOGIC, lImplicitSSLTLS AS LOGIC, lSSL AS LOGIC, lTLS AS LOGIC, lQuiet AS LOGIC) AS OBJECT PASCAL CLASS FtpAX

The init is strong typed, declared in the class, but the missing parameter does not give a compiler error in VO.

Dick

Strong typed init, no compiler error on missing parameters?

Posted: Thu Dec 16, 2021 1:59 pm
by robert
Dick,

VO does not support strongly typed constructors.
The compiler converts all class creations into a call to CreateInstance(....)

Robert

Strong typed init, no compiler error on missing parameters?

Posted: Thu Dec 16, 2021 2:54 pm
by ic2
Hello Robert,

Ah! I thought I knew this but I also though that you just couldn't create strong typed init's but it compiled fine. So even after all these years VO still surprises us from time to time.

Dick

Strong typed init, no compiler error on missing parameters?

Posted: Thu Dec 16, 2021 4:02 pm
by robert
Dick,

You will see the same problem when you strongly type a method and call it late bound. In that case you will also not be notified of missing parameters.


Robert