Wish maxParams could be set by user

Propose new features and changes
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Wish maxParams could be set by user

02 Jan 2024, 00:21

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.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Wish maxParams could be set by user

19 Jan 2024, 02:12

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.
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Re: Wish maxParams could be set by user

19 Jan 2024, 05:14

Maybe keeping it as current, is better.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 123 guests