Page 1 of 1

Wish maxParams could be set by user

Posted: 02 Jan 2024, 00:21
by V2User
This code would probably like to throw, but it won't currently:

Code: Select all

f(*)=>OutputDebug(22)
c:=f.Bind(1)
c.DefineProp('MaxParams',{value:1})
c.DefineProp('MinParams',{value:1})
c.DefineProp('IsVariadic',{value:0})
c(2,3)
So, I wish a func's MaxParams, MinParams, IsVariadic could be set by user customizable.

Re: Wish maxParams could be set by user

Posted: 19 Jan 2024, 02:12
by lexikos
Noted; however:

Redefining a property is not setting a property. The built-in property already exists, and is rightly not invoked when you shadow it with a new property.

A bound function currently does not impose any restriction on the number of parameters. It accepts whatever parameters are passed, combines them with whatever parameters are bound, and attempts to invoke the bound object. The bound object delegates to the implementation of whatever method (or the function itself in this case), and only then the parameter count is checked.

Rather than (or in addition to) redefining MaxParams, you can redefine Call and impose whatever restrictions you want.

Re: Wish maxParams could be set by user

Posted: 19 Jan 2024, 05:14
by V2User
Maybe keeping it as current, is better.