V2 doesn't have commands as v1, you can omit the parentheses when you call a function or method at the beginning of a line, and discard the return value.
Sharing variable and function namespace is highly unsuitable for ahk. If names where case sensitive it might be acceptable.
Cheers.
ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
By command syntax I just mean function calls without parenthesis. Not sure why the function still has to be the first word in a line.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
Not sure why the function still has to be the first word in a line.
Code: Select all
z := x -y
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
By the way, command syntax, as known from v1 is very different from function calls without (), there is no inital comma and only expressions for the parameters, no literal text or forced expressions. Also, methods can be called this way, eg, obj.m par*, there is no such syntax in v1. I'm sure you know this but others less familiar with v2 might be confused if the term command syntax is used when we mean function calls without () in v2.
Cheers.
Cheers.
-
- Posts: 100
- Joined: 20 May 2014, 21:24
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
According to my understanding of the changes, that is misleading. Foo(X, Y) can be called as Foo(1, 2) or Foo 1, 2. Given that, one could reasonably argue command syntax is alive and well.
This situation also creates 'fun' mental puzzles...
Consider the (perfectly reasonable) line Foo A, B . Bar D, E.
I know the answer to how this should be parsed is Foo(A, B) . Bar(D, E), but I do not look forward to having to untangle that. That requires me to keep in mind that commas immediately after command names are now forbidden. If I forget that, I might misunderstand it as Foo(A, B . Bar, D, E) or if I was used to v1 Foo(A, B . Bar . D, E).
Now consider the fun when one starts using the , operator to splice lines together.
I already have to remember how to cope with the % plague and that ! has the wrong precedence, copied from C (so always use not instead). Then there are all of the bad ideas that I should never use in real code, like assignment in an expression, including ++ and --, also copied from C. Good luck puzzling out the order of side effects, especially if more than one assignment is used in an expression!
And those are just AutoHotkey's bad parts involving syntax!
This is anything but 'easy'. Will a description of how parsing works be in the manual? Will we finally get to see the excuse for being told to shove everything onto one line to get a 35% speed boost? Do you really expect beginner programmers to understand this and keep it in mind along with everything else relevant to solving the problem their program is meant to solve?
I wish the developers would stop trying to be clever with syntax. At this point I would suggest they just rip off C syntax like every other new programming language. C syntax is bad, but it is still better than AutoHotkey's. If you can't beat 'em, join 'em. And what I just described is definitely not beating 'em.
I wish they would stop trying to be clever with semantics too. The behavior of the ~ operator, arrays with missing elements (consider the fun with array length when sorting or reversing such arrays), and every object is a dictionary with unreliable indexing that conflates its interface and contents, except built-in objects (gotta keep you on your toes), are just a few examples of things that should have never happened. If nobody else did something or everyone else says something is bad (e.g. goto in a high-level language), do not do it unless you can prove it is an improvement. There is a really good reason that most modern programming languages do not have operators that behave differently depending on the value they operate on, their arrays do not have missing elements, their dictionaries do not change the values of their keys or conflate their members and contents, their built-in constructs behave like user-defined constructs, and they do not have control flow constructs that can bypass initialization.
That new behavior where everything is 'truthy' or 'falsey' makes me want to scream. It is bad enough that I have to remember that true and false are 1 and 0 (respectively) in certain contexts (e.g. when trying to visualize a data structure to do some debugging because the debugger is inadequate and there is no REPL), but now they could be anything. There are alternatives you know. Some languages, like Scheme, Python, and C#, have dedicated boolean values. If you want a null coalescing operator, introduce a new one (probably MaybeEmptyString ?? Default) with a high priority (after object access and before new or anything else; do not repeat C#'s and Swift's mistake of making it low priority) instead of abusing or.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
You understand it wrong then. Command syntax is not simply omitting (), as I noted above, hence, calling it command syntax is what is actually misleading.According to my understanding of the changes, that is misleading.Command Syntax has been removed in v2.
It shouldn't, and it isn't. It is parsed as Foo(A, B . Bar D, E)Consider the (perfectly reasonable) line Foo A, B . Bar D, E.
I know the answer to how this should be parsed is Foo(A, B) . Bar(D, E)
Cheers.
-
- Posts: 100
- Joined: 20 May 2014, 21:24
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
If I understand you correctly this means that a command must appear on a line by itself and cannot be used with comma splicing (or whatever we are supposed to call it).Helgef wrote: ↑17 Nov 2018, 10:48You understand it wrong then. Command syntax is not simply omitting (), as I noted above, hence, calling it command syntax is what is actually misleading.According to my understanding of the changes, that is misleading.Command Syntax has been removed in v2.It shouldn't, and it isn't. It is parsed as Foo(A, B . Bar D, E)Consider the (perfectly reasonable) line Foo A, B . Bar D, E.
I know the answer to how this should be parsed is Foo(A, B) . Bar(D, E)
Cheers.
To me, that still sounds like command syntax. I am not clear on how it is any different than before other than all functions can be used that way now and there is apparently a lack of out variables, making it even less usable.
Implicit concatenation is back in v2? Yuck! Last I remember, it was going to be removed.
In any case, it sounds like there will still be large portions of the language that do not work well, so I will need to ignore them and hope I do not need to deal with them in others' code.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
The difference to normal commands is that all parameters are expressions - they were not expressions in v1.
Recommends AHK Studio
-
- Posts: 100
- Joined: 20 May 2014, 21:24
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
That seems to remove the need for %. I am skeptical about whether it is truly unnecessary in v2. For example, loop, which cannot be function, almost always required % shenanigans.
Also, given how defanged these new commands must be, I do not understand why they were not removed entirely. It is one more thing to learn that does not allow you to do anything better or new.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
% is completely removed - no need to be skeptical everything is an expression.
Recommends AHK Studio
-
- Posts: 100
- Joined: 20 May 2014, 21:24
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
How would I loop for a certain number of times using an expression? How would I loop over lines in a file where the file comes from an expression?
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
In expressions numbers are just numbers:
If you want to iterate over each line in a file using expressions I would suggest this:
I think this has slightly gone offtopic from your initial suggestion though - it might be better to ask this in Ask For Help
Code: Select all
Loop 13 {
}
Code: Select all
for each, line in StrSplit(FileOpen(fileName, "r").Read(), "`n", "`r") {
}
Recommends AHK Studio
-
- Posts: 100
- Joined: 20 May 2014, 21:24
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
The hard coded 13 does not answer the question. The other does, I suppose, but does not use loop, which was the point. I will head off though. It sounds like nothing will be done because of my complaints.nnnik wrote: ↑17 Nov 2018, 12:52In expressions numbers are just numbers:If you want to iterate over each line in a file using expressions I would suggest this:Code: Select all
Loop 13 { }
I think this has slightly gone offtopic from your initial suggestion though - it might be better to ask this in Ask For HelpCode: Select all
for each, line in StrSplit(FileOpen(fileName, "r").Read(), "`n", "`r") { }
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
Well you can always implement something yourself.
Im not sure if lexikos will accept it.
I just wanted to share my experience from attempting a similar thing and which problems arose during implementation.
I might add a .bind method to the boundfunc object next week and make a pull request.
lexikos has rejected most of my pull requests so far though.
Im not sure if lexikos will accept it.
I just wanted to share my experience from attempting a similar thing and which problems arose during implementation.
I might add a .bind method to the boundfunc object next week and make a pull request.
lexikos has rejected most of my pull requests so far though.
Recommends AHK Studio
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
No this is AutoHotkey, so the comma operator has the least precedence.Helgef wrote: ↑17 Nov 2018, 10:48You understand it wrong then. Command syntax is not simply omitting (), as I noted above, hence, calling it command syntax is what is actually misleading.According to my understanding of the changes, that is misleading.Command Syntax has been removed in v2.It shouldn't, and it isn't. It is parsed as Foo(A, B . Bar D, E)Consider the (perfectly reasonable) line Foo A, B . Bar D, E.
I know the answer to how this should be parsed is Foo(A, B) . Bar(D, E)
Cheers.
Foo A, B . Bar D, E is Foo(A), B . Bar(D), E which is interpreted
Edit: This could be done by making "command" syntax short circuit at the first set of parenthesis?
You are mixing AHK with Python which allows x,y = y,x as a swap operation. In AHK this swap must be (x,y) := (y,x) if it is ever implemented, and I hope it is not.
Last edited by iseahound on 17 Nov 2018, 14:28, edited 2 times in total.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
In Haskell, unary operators are the exception. unfortunately x(-y) would be the interpretation if x is a function. Still AHK programmers can write x-y or x - y which is much clearer.Helgef wrote: ↑17 Nov 2018, 06:34Not sure why the function still has to be the first word in a line.is substraction, it cannot be interpreted as x(-y), as an example.Code: Select all
z := x -y
Also, can you recommend a name for this function call without parenthesis if we are not to use the term "command syntax"? I have no doubt that "command" will persist in AHK lingo, but what do you suggest? Thanks.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
[Shambles] wrote: ↑17 Nov 2018, 12:14How would I loop for a certain number of times using an expression? How would I loop over lines in a file where the file comes from an expression?
you do it the same way everyone has been telling you to do it. simply pass a fkn expression. why don't you just RTFM and open up a text editor:[Shambles] wrote: ↑17 Nov 2018, 13:03The hard coded 13 does not answer the question. The other does, I suppose, but does not use loop, which was the point. I will head off though. It sounds like nothing will be done because of my complaints.
https://lexikos.github.io/v2/docs/commands/Loop.htm
https://lexikos.github.io/v2/docs/commands/LoopRead.htm
at this point it sounds like you're just searching for stuff to complain about.
Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change
Indeed this is AutoHotkey, and in AutoHotkey the comma (,) in a parameter list isn't the comma operator but just a symbol separating the parameters. In autohotkey you are lucky that your mistake of mistaking the comma in a paramter list for the comma operator doesn't cause you much problems, because in AHK the order of evaluation of expressions in a parameter list, f(a,b,c) is the same as in (a,b,c). If you make the same mistake in C, you will be unpleasantly surprised.No this is AutoHotkey, so the comma operator has the least precedence.
This will pass B . Bar . E to Foo, the result of A and D will be discarded.You would be forced to write Foo (A, B) . Bar (D, E) which is very reasonable and easy to interpret.
Nope.You are mixing AHK with Python
It is a function call, consequently, that is what we should call it (and o.m p* is a method call).Also, can you recommend a name
Cheers.
Who is online
Users browsing this forum: No registered users and 28 guests