ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

Propose new features and changes
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 03:30

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.
iseahound
Posts: 355
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 06:29

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.
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 06:34

Not sure why the function still has to be the first word in a line.

Code: Select all

z := x -y
is substraction, it cannot be interpreted as x(-y), as an example.
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 06:40

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.
[Shambles]
Posts: 51
Joined: 20 May 2014, 21:24

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 07:06

nnnik wrote:
17 Nov 2018, 03:27
Command Syntax has been removed in v2.
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.

Image
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 10:48

Command Syntax has been removed in v2.
According to my understanding of the changes, that is misleading.
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.
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)
It shouldn't, and it isn't. It is parsed as Foo(A, B . Bar D, E)

Cheers.
[Shambles]
Posts: 51
Joined: 20 May 2014, 21:24

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 10:56

Helgef wrote:
17 Nov 2018, 10:48
Command Syntax has been removed in v2.
According to my understanding of the changes, that is misleading.
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.
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)
It shouldn't, and it isn't. It is parsed as Foo(A, B . Bar D, E)

Cheers.
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).

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.
User avatar
nnnik
Posts: 3541
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 11:33

The difference to normal commands is that all parameters are expressions - they were not expressions in v1.
Recommends AHK Studio
[Shambles]
Posts: 51
Joined: 20 May 2014, 21:24

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 11:54

nnnik wrote:
17 Nov 2018, 11:33
The difference to normal commands is that all parameters are expressions - they were not expressions in v1.
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.
User avatar
nnnik
Posts: 3541
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 11:58

% is completely removed - no need to be skeptical everything is an expression.
Recommends AHK Studio
[Shambles]
Posts: 51
Joined: 20 May 2014, 21:24

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 12:14

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?
User avatar
nnnik
Posts: 3541
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 12:52

In expressions numbers are just numbers:

Code: Select all

Loop 13 {

}
If you want to iterate over each line in a file using expressions I would suggest this:

Code: Select all

for each, line in StrSplit(FileOpen(fileName, "r").Read(), "`n", "`r") {

}
I think this has slightly gone offtopic from your initial suggestion though - it might be better to ask this in Ask For Help
Recommends AHK Studio
[Shambles]
Posts: 51
Joined: 20 May 2014, 21:24

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 13:03

nnnik wrote:
17 Nov 2018, 12:52
In expressions numbers are just numbers:

Code: Select all

Loop 13 {

}
If you want to iterate over each line in a file using expressions I would suggest this:

Code: Select all

for each, line in StrSplit(FileOpen(fileName, "r").Read(), "`n", "`r") {

}
I think this has slightly gone offtopic from your initial suggestion though - it might be better to ask this in Ask For Help
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.
User avatar
nnnik
Posts: 3541
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 13:09

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.
Recommends AHK Studio
iseahound
Posts: 355
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 13:37

Helgef wrote:
17 Nov 2018, 10:48
Command Syntax has been removed in v2.
According to my understanding of the changes, that is misleading.
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.
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)
It shouldn't, and it isn't. It is parsed as Foo(A, B . Bar D, E)

Cheers.
No this is AutoHotkey, so the comma operator has the least precedence.

Foo A, B . Bar D, E is Foo(A), B . Bar(D), E which is interpreted as a multiline statement running Foo(A), string concatenation of B and Bar(D) (that is not captured), and an assertion of E that is not captured. as a command of foo. You would be forced to write Foo (A, B) . Bar (D, E) which is very reasonable and easy to interpret.

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.
iseahound
Posts: 355
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 13:45

Helgef wrote:
17 Nov 2018, 06:34
Not sure why the function still has to be the first word in a line.

Code: Select all

z := x -y
is substraction, it cannot be interpreted as x(-y), as an example.
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.

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.
guest3456
Posts: 2469
Joined: 09 Oct 2013, 10:31

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

17 Nov 2018, 21:26

[Shambles] wrote:
17 Nov 2018, 12:14
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?
[Shambles] wrote:
17 Nov 2018, 13:03
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.
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:

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.

Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: ObjGetBase(Object) and ObjSetBase(Object, BaseObject) Need to Change

18 Nov 2018, 09:44

No this is AutoHotkey, so the comma operator has the least precedence.
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.
You would be forced to write Foo (A, B) . Bar (D, E) which is very reasonable and easy to interpret.
This will pass B . Bar . E to Foo, the result of A and D will be discarded.
You are mixing AHK with Python
Nope.
Also, can you recommend a name
It is a function call, consequently, that is what we should call it (and o.m p* is a method call).

Cheers.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 7 guests