Old 02-25-2020, 06:39 PM   #1
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 809
Default passing a function as an argument

Is this a thing? I could have sworn that I saw it once in someone's code but I'll be danged if I remember where. Looking to see if anyone knows how, my google fu isn't turning up anything.

I'm looking for something like this:

Code:
function modA(func)
 instance(a)
(
  a = func(a);
);

obj.modA( invert() );
obj.modA( scale() );
Does it exist? What's the proper syntax?
SaulT is offline   Reply With Quote
Old 02-26-2020, 12:21 AM   #2
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 863
Default

I don't think there's a way to pass functions in jsfx. You could send a variable, and call a function in the inner loop which looks up and calls the function you actually want. But yeah, not pretty with lots of branching.

If possible, I would have expected a syntax without the ().
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [Filther: Thread|Github|Reapack] | [More JSFX: Thread|Reapack]
sai'ke is offline   Reply With Quote
Old 02-26-2020, 06:14 AM   #3
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,480
Default

No, you can't pass a function in JS/EEL (unless I missed something big!). You can pass a pseudo-object reference using func(namespace*), maybe that's what you remember?
IXix is online now   Reply With Quote
Old 02-28-2020, 01:04 AM   #4
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 809
Default

Quote:
Originally Posted by IXix View Post
No, you can't pass a function in JS/EEL (unless I missed something big!). You can pass a pseudo-object reference using func(namespace*), maybe that's what you remember?
Ok, that's what I saw. Thanks, that sinks one ship but possibly floats a different one.
SaulT is offline   Reply With Quote
Old 02-28-2020, 03:50 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,480
Default

Quote:
Originally Posted by SaulT View Post
that sinks one ship but possibly floats a different one.
lol
IXix is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.