Is a closure a custom function ?

49 views
Skip to first unread message

Chris Blackwell

unread,
Apr 16, 2015, 9:10:09 AM4/16/15
to lu...@googlegroups.com
I just noticed that (on lucee 4.5.1.008)

isCustomFunction(function(){}) returns false

Is this the expected behaviour?

I can see that a UDF wouldn't be a closure, but isn't a closure a "Custom Function"?


Dominic Watson

unread,
Apr 16, 2015, 9:49:32 AM4/16/15
to lu...@googlegroups.com
A distinction has been made between a UDF and a closure. You can use: IsClosure( someVariable ) to detect closures.

I think it would be useful to have an additional validator function that would return true for both types, IsFunction()?

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAB%3DtfTqA4p8t2J0ZMHNeOy4a25ofZHcBS9GP2N366Pgrdwj4_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Pixl8 Interactive, 3 Tun Yard, Peardon Street, London
SW8 3HT, United Kingdom

T: +44 [0] 845 260 0726 W: www.pixl8.co.uk E: in...@pixl8.co.uk

Follow us on: Facebook Twitter LinkedIn
CONFIDENTIAL AND PRIVILEGED - This e-mail and any attachment is intended solely for the addressee, is strictly confidential and may also be subject to legal, professional or other privilege or may be protected by work product immunity or other legal rules. If you are not the addressee please do not read, print, re-transmit, store or act in reliance on it or any attachments. Instead, please email it back to the sender and then immediately permanently delete it. Pixl8 Interactive Ltd Registered in England. Registered number: 04336501. Registered office: 8 Spur Road, Cosham, Portsmouth, Hampshire, PO6 3EB

Michael Offner

unread,
Apr 16, 2015, 10:07:33 AM4/16/15
to lucee
we have changed the functionlaity for Lucee 5.
Lucee 5 returns true for udf,closure and lambda, but we also added a new argument "type", so you can do:
isCustomFunction(udf,"closure");

Micha

Chris Blackwell

unread,
Apr 16, 2015, 10:13:46 AM4/16/15
to lu...@googlegroups.com
Thanks Micha,

That makes sense to me as i see all of those as types of custom function.

@Dominic
yes, aware of that function, but given the current implementation i have to check both e.g

if(isClosure(obj) || isCustomFunction(obj))

given the changes Micha has indicated for Railo 5, this becomes just

if(isCustomFunction(obj)) 

Cheers, Chris




Dominic Watson

unread,
Apr 16, 2015, 10:18:39 AM4/16/15
to lu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages