AutoHotkey Community

It is currently May 27th, 2012, 12:57 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: September 22nd, 2011, 2:56 am 
Using a library is more complicated for programming beginners.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 3:12 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Anonymous wrote:
Using a library is more complicated for programming beginners.

A Standard Library comes packaged with AHK. There is no room for complication if using the AHK installer. Too many built-in vars complicates things though ...

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 3:22 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Anonymous wrote:
then why not?
It doesn't seem worthwhile in terms of time and code/documentation size. That's reason enough for me.
Anonymous wrote:
This is more accurate.
It's not valid code. Obviously the value will be used in some context, and assigning it to a variable is the simplest context to demonstrate. If you're going to remove one assignment, to be fair you must also remove the DllCall assignment; so your point is moot.
jaco0646 wrote:
I suggest that from now on, every proposal for a new constant must also propose an existing constant to delete.
I like that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 4:38 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
I think more useful constants than A_ScriptPID are things like A_CoordModeMouse, and other "missing" settings variables such as A_SendMode

Then, delete all date/time variables and use formatTime instead. After all, date/time variables save the same amount of code as A_ScriptPID would: one line :idea:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 4:54 am 
Lexikos wrote:
It's not valid code. Obviously the value will be used in some context, and assigning it to a variable is the simplest context to demonstrate. If you're going to remove one assignment, to be fair you must also remove the DllCall assignment; so your point is moot.
If you want valid code then,
Code:
Process Exist ; (and then just use ErrorLevel)
; or
pid := DllCall("GetCurrentProcessId")
; -->
`(A_ScriptPID)
But the purpose of assigning a value to a variable is for later use. That means even `(A_ScriptPID) won't be necessary in this comparison.
Code:
Process Exist ; (and then just use ErrorLevel)
; or
pid := DllCall("GetCurrentProcessId")
; -->
;none!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 6:38 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
I wrote:
If you're going to remove one assignment, to be fair you must also remove the DllCall assignment; so your point is moot.
The DllCall doesn't need to be assigned to a variable either.
Code:
;none!
; -->
;none!
:roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 7:41 am 
Lexikos wrote:
The DllCall doesn't need to be assigned to a variable either.
It depends on the context. Some perefer to hold the value in a variable to use it in the traditional method, to use it multiple times, or to just make it readable. So in the code example, if the assignment, pid := DllCall("GetCurrentProcessID") is used for such usage, A_ScriptPID does not have to be assigned to a variable because it already has the value in it. FYI, this search result may prove how often a variable is used for a PID instead of the function call.

Also, the process id doesn't change until the script exits. So every time retrieving the PID, it is more rational to use the stored value in a variable rather than calling the function. And a value which does not change throughout the whole code execution is a good candidate to be a constant.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 2:40 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
Off-topic, but the idea of A_HWND.A_Gui or A_HWND.A_GuiControl can be good and possible ? (same for script, name, path, ext and other)
I wonder if we can create "superglobal pseudo object" for have less built in variable and more generic word, and creat complexe variable like into an agglutinative language.

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 9:07 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Grouping some of the variables by topic might be useful in AHK v2 if it should move its focus towards a professional programming language. I'm not sure if it is required though or how much actual gain there would be.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 9:22 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
fragman wrote:
how much actual gain there would be

One thing what comes to my mind is, it would help to reduce the possibility of naming clash. But this is not real world problem, as nearly nobody names the variables beginning with A_. In fact, I am not sure why all variables should be grouped in an arrray (in example as A.ScriptName). Consistency is the only reason, I think.

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 24th, 2011, 1:55 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
Dunno, maybe I say too much stupid thing :D We can have a feature as this too , and it's customizable... However if we have A.Index then I have ton of doubt about peformance.
Code:
A := new BuiltInVar

MsgBox % A.TickCount "|" A.TitleMatchMode "`n" a_tickcount "|" a_titlematchmode

A.TitleMatchMode := 2
A.TickCount := "can not be changed"

MsgBox % A.TickCount "|" A.TitleMatchMode "`n" a_tickcount "|" a_titlematchmode

class BuiltInVar
{
  __Get(aName) {
    if (aName = "TickCount")
      return % A_TickCount
    if (aName = "TitleMatchMode")
      return % A_TitleMatchMode
    return
; return % A_%aName%
  }
  __Set(aName, aValue) {
    if (aName = "TitleMatchMode")
      SetTitleMatchMode, % aValue
    return
  }
}

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group