Here's a simple example of passing a function to another function:

proc myfunc(x:int) {

  writeln(x+1);

}


proc apply(f, y) {

  f(y);

}


apply(myfunc, 42);


________________________________
From: Brad Chamberlain <[email protected]>
Sent: Sunday, November 5, 2017 10:35:22 PM
To: Damian McGuckin; [email protected]
Subject: Re: [Chapel-developers] Procedure arguments which are themselves 
procedures


Hi Damian --


See: https://chapel-lang.org/docs/latest/technotes/firstClassFns.html


I believe there are some capabilities that may work yet not be documented here, 
so give a shout if there's something you want to do beyond what's covered here.


-Brad


________________________________
From: Damian McGuckin <[email protected]>
Sent: Sunday, November 5, 2017 9:11:49 PM
To: [email protected]
Subject: [Chapel-developers] Procedure arguments which are themselves procedures


Hi All,

How does one specify a procedure to be an argument of another procedure?

Maybe I am looking for (grep'ing)  the wrong mix of words but I cannot
find an example in the specification.

Thanks - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to