Browse source

Changelog

Query
From:
To:
Branch:
Path:
Message:
BugID:
User: +
Format:
: 1 checkin (+177/-0) by Per Hedbor <ph@opera.com> Lines added/removed recently

Monday 30 May 2016

2016-05-30 20:37:45 (4 years ago) by Per Hedbor <ph@opera.com>

Added C++11-alike Function.bind functionality.

This is somewhat similar to Function.curry, but more dynamic.

However, the usage is somewhat cumbersome, you have to use
placeholders if you want anything except static arguments.

As an example:

import Function.Placeholder;
function add_6 = Function.bind( `+, arg0, 6 );

This returns a function that adds 6 to it's only argument (in that
order, unlike curry which would be the other way around)

Function.Placeholder has these useful indices:

o argN -- takes argument N from the call
o rest -- All unused arguments (by argN, Arg(N) or Splice)
o Splice(start[,end]) arguments from start (if end is not specified, all arguments)
o Arg(N) similar to argN, but N can be negative
o Expr(func[,splice]) Call func with arguments, use return value
if splice is true, returns an array to be @:ed.

Things to do:

The syntax is rather horrid, really.
Is there a way to get a more reasonable one?

[permalink]

Bugs? Suggestions?