Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should commands use lowercase or CamelCase? #3

Open
Stevoisiak opened this issue Aug 11, 2017 · 3 comments
Open

Should commands use lowercase or CamelCase? #3

Stevoisiak opened this issue Aug 11, 2017 · 3 comments

Comments

@Stevoisiak
Copy link

Stevoisiak commented Aug 11, 2017

Can there be a section discussing a consistent capitalization style for commands and variables?

^j::
    msgbox, Hello World! ; lowercase
    msgBox, Hello World! ; camelCase
    MsgBox, Hello World! ; CamelCase
    MSGBOX, Hello World! ; UPPERCASE
return

Most coding guides seem to use a mixture of lowercase and CamelCase. Take this example from the AutoHotkey Beginner tutorial.

2 - Hotkeys & Hotstrings

^j::
    MsgBox Wow!                            ; CamelCase
    MsgBox this is                         ; CamelCase
    Run, Notepad.exe                       ; CamelCase
    winactivate, Untitled - Notepad        ; lowercase
    WinWaitActive, Untitled - Notepad      ; CamelCase
    send, 7 lines{!}{enter}                ; lowercase
    sendinput, inside the ctrl{+}j hotkey  ; lowercase
Return                                     ; CamelCase

Even this repository mixes CamelCase and lowercase. (Examples from Flow of Control and Commands)

if var = AHK
    msgbox match  ; lowercase
WinClose Notepad  ; CamelCase
@Stevoisiak Stevoisiak changed the title Should commands be lowercase or CamelCase? Should commands use lowercase or CamelCase? Aug 11, 2017
@aviaryan
Copy link
Owner

Good question.
I definitely prefer ProperCase over any other alternatives.
Since MsgBox is also a command, it should be ProperCase as well. What do you think?

@Stevoisiak
Copy link
Author

Stevoisiak commented Aug 11, 2017

I like guest3456's suggestion on the AHK forums.

  • lowercase for Control Flow statements: if, else, return, while
  • CamelCase for regular commands/functions: MsgBox, Send, WinActivate

The only downside is that the distinction between the two categories could be confusing for commands like IfWinActive, SetTimer, OnExit.

I haven't really put enough thought into the best style for variable names.

As for variable names, RaptorX suggests using a mix of lowercase and CamelCase. (strLength, fstLetter, myString)

@Stevoisiak
Copy link
Author

Stevoisiak commented Aug 21, 2017

@aviaryan After doing some more research, I think it makes more sense to look to jNizM's AHK Syntax Highlighting addon for Notepad++ for guidance. (also on GitHub)

Like guest3456 had suggested, the AutoCompletion addon uses CamelCase for regular commands and functions. However, the implementation of control flow statements is a bit inconsistent.

In the provided screenshot, control flow statements like if, return, loop, and byref are lowercase. However, in my personal testing (image below), I've found that the autocomplete recommends CamelCase for these statements.

(Note: Color differences are due to me using the Default AHK theme, while the official screenshots use the "Lazy" Theme.)

Local screenshot of NotePad++ AHK AutoComplete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants