CLASS / DATA, VAR... REQUIRED (New feature)

175 views
Skip to first unread message

Hurricane

unread,
Feb 13, 2025, 2:24:46 PM2/13/25
to harbou...@googlegroups.com
A suggestion, could someone add this feature to Harbour?!
syntax (hbclass.ch) and scope (HB_OO_CLSTP_REQUIRED)

This small change will help the class creator to automate this type of validation at strategic points.

CLASS TTest
   DATA cKey      INIT ''              REQUIRED
   DATA cModel    INIT '...ai_name...' REQUIRED
   DATA cURL                           REQUIRED
   ...
ENDCLASS

Once I'm done, I can share the code.



Changing the subject a little...
Is it possible to enable parameter checking for a method? The compiler will warn you when the implementation is different from the declaration.
I did some tests and I couldn't

CLASS TTest
   METHOD send( cURL )
ENDCLASS

METHOD send( cURL, xData ) CLASS TTest
   RETURN NIL

Regards,
Hurricane

Francesco Perillo

unread,
Feb 13, 2025, 2:50:14 PM2/13/25
to harbou...@googlegroups.com, harbou...@googlegroups.com

Harbour is a dynamic non typed language and has constructs as ... or pcount() OR HB_APARAMS() (if i remember correctly) so it would be a bit strange to add the feature you request...

Btw, it would be a great addition! But it would be another language...


--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/530722945.12289521.1739474639408%40mail.yahoo.com.

david...@gmail.com

unread,
Feb 19, 2025, 5:47:09 PM2/19/25
to Harbour Users
Hi,

>>Is it possible to enable parameter checking for a method? The compiler will warn you when the implementation is different from the declaration.

Use compiler option -w3

METHOD TableExist(cTable, a)

METHOD Function TableExist(cTable) CLASS ADOC
...

Compiler response is:
\Programas\dbAdo.prg(69) Warning W0001  Method <TableExist(cTable)> not declared or declaration mismatch in class <ADOC>

Regards,
David Field
Reply all
Reply to author
Forward
0 new messages