what's the rule here:
# lucee
d
what's the rule here:
Copy code
var isArray = (required any v) => {
	return isArray(v);
           ^^^^^^^^^^ name lookup finds bif
}

x = [[],0,[]]

writedump(x.map(isArray)) // [true,false,true]
                ^^^^^^^ name lookup finds NON-bif
a call expression finds BIFs; non-call-expressions don't look into BIF table?
b
I'm not quite sure what you're trying to test there.
I do know BIFs can't be passed as a UDF into higher order functions.
d
i'm not trying to test anything
b
Well, you're trying to SHOW something, lol
Whatever you want to call it 🙂
d
I guess I want to know if this lookup rule is consistent everywhere
b
Copy code
x.map(isArray)
☝️ I'm fairly sure that would never find a BIF and would only reference a UDF of that name
d
if you say
builtinfunction
vs
builtinfunction()
, that is the trigger to find BIF vs not find BIF (ok that's what I'm trying to test)
b
BIFs are not defined as variables on the page. Does that help.
d
Copy code
var now = now(); // no problem
i guess it's the parens
b
Copy code
var myFunc = ()=>{}
local.keyExists( 'myFunc' ) // true
local.keyExists( 'dateFormat' ) // false
d
baked into the bytecode i suppose
b
Well, parens are how you invoke a method.
d
Copy code
var now = () => { return 42; }
var foo = now(); // calls bif
b
But since BIFs don't live in the variables scope, there's no concern of
now
somehow being a reference to a BIF.
I'm wanting to say with no scope in place (meaning
local.now()
), BIFs are given precedence over a UDF of the same name in a searchable scope.
Which is why legacy code I've run across that has a CFC method with the same name as a BIF had to change to
this.render()
to still work inside the CFC.
d
yeah ok, unqualified name lookup on a function call finds BIFs first;
local.now
would find "my" now
👍 1
b
Yep, and if that wasn't the case, we basically wouldn't be able to have any variables with the same name as a BIF.