Code: Select all
greet := name => 'hello, ' name
msgbox greet.Call('world') ; too long
msgbox %greet%('world') ; too percenty
msgbox greet('world') ; non-existent function
Code: Select all
greet := name => 'hello, ' name
msgbox greet.Call('world') ; too long
msgbox %greet%('world') ; too percenty
msgbox greet('world') ; non-existent function
I agree, it stings in my eyes, but I can not give any other reason why we need a change.; too percenty
You wish for lambdas. Lambdas exist in v2. How am I not making sense?Callable Func, BoundFunc, lambdas, custom user objs(ie no %%)
If that's your wish, you should have put that in the title... Instead you chose to put "callable funcs", which already exist; "callable BoundFuncs", which already exist; "lambdas" which already exist in v2, and "callable custom user objs"...the wish is to make callables callable without having to resort to %%-sign deref or .Call().
I'm not going to unsubscribe from a topic which interests, just me because there is an off topic discussion which doesn't interest me, you know...SALZKARTOFFEEEL wrote: ↑06 Feb 2019, 01:24You know, you can always just unsubscribe from the topic.
Code: Select all
class PercentlessCallable
{
Call(greeting, name) {
MsgBox greeting ', ' name '!'
}
__Item[greeting, name] {
get {
return this.Call(greeting, name)
}
}
}
fn := new PercentlessCallable()
fn['Hello', 'world']
Nope, we're getting more of it, obj[expr](params) is being replaced by obj.%expr%(params). obj[prop_name_expr] is being replaced with obj.%prop_name_expr%.we're getting there
Code: Select all
/*
'fn' reserved keyword takes the resolved name of the variable that follows
and assigns that name to the lambda that follows, effectively declaring a function with that name
fn greet := name => 'hello, ' name
becomes internally
greet := greet(name) => 'hello, ' name
*/
greet := greet(name) => 'hello, ' name ; for demo purposes only, in the actual script this line would read: fn greet := name => 'hello, ' name
msgbox greet('world') ; calls the named lambda
msgbox lambdaCaller(greet, 'world') ; passing the lambda, stored in the variable, as a variable still supported
lambdaCaller(fn, Args*) { ; to simulate a function accepting a lambda and doing something with it
return fn.Call(Args*)
}
var () .I might consider allowing () as an operator applied to any expression which is not otherwise recognized as a function call; however, it would have to be (var)(), not var(),
I suppose it would work if a local var took precedence over a global function, egbiased against any other propositions diverging from var()
Code: Select all
f(){
local var := func('a')
var() ; calls func('a')
}
var(){
}
Code: Select all
var := ... ; anything
var() ; error
var(){
}
thats exactly it. reminds me of these few posts
https://www.autohotkey.com/boards/viewtopic.php?p=41939#p41939[Shambles] wrote:One example is the use of % (note: non-directional, unlike [], {}, and <>) brackets for substitution.
[Shambles] wrote:% is particularly problematic, because it is used both as brackets, and alone. The bracketed form is especially hard to read, because unlike ‘normal’ brackets, % is not directional.
why is it important to make this distinction? for example, C doesnt. neither does JS. why is it important to know whether the thing im calling is a callback or a hardcoded function
its only intuitive if uve spent most of ur time writing AHK Basic scripts
Users browsing this forum: No registered users and 11 guests