Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Clean Up Code


  • Please log in to reply
58 replies to this topic
hamoid
  • Members
  • 19 posts
  • Last active: Nov 06 2006 10:45 AM
  • Joined: 17 Mar 2005

there is little in common between Pascal (and dialects), C (and variants), Basic (mostly the Visual one), Perl, Python, to name but a few "popular" languages...


Maybe they don't have so much in common (functions in all are called with parenthesis?), but it's just the fact of using a new syntax instead of an existing one.

I think it would help Chris very much if a existing parser was used, since he could then only concentrate in functionality, not in the language itself. And we wouldn't discuss if we prefer having ;'s or {}'s or ...

But I don't complain :) AHK saves me a lot of clicks and keystrokes every hour I use my PC.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I think it would help Chris very much if a existing parser was used, since he could then only concentrate in functionality, not in the language itself. And we wouldn't discuss if we prefer having ;'s or {}'s or ...

I think so too, but now we have lot of legacy code we can't drop just like that...
And choosing a parser, ie. a language, will be controversial as well! Some will be happy, others will complain it is too complex, too verbose, too cryptic (lot of symbols...), too big, too slow, having a syntax not meeting their taste (too Basic, too Pascal, too C...) and so on.
Let's live with what we have, improving it as much as possible.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Its good to heave possibility [of multiple statements on the same line].

I agree. I merely said that I think it shouldn't be given a high priority compared to other things like true arrays and v2 itself. In addition, making such a feature a part of v2 would delay the release of #v2 because it would involve a redesign of the parser.

I hope you understand that your opinion about readability is highly subjective and you can't find any "real" reason not implement this. Its just principle of yours, and those can't be right or wrong, its just the way you do things.

I only said that seems much lower priority than other planned features. I could easily be wrong about its importance; so if you or anyone else feels it should be a top priority, feel free to have a poll about it.

Finally, I've considered having more polls to decide the direction of AutoHotkey. However, setting them up would take time away from design and development (for which there is already little time), so I don't know if it would be worth it.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
About multiple statements on the same line:
Obviously, it is useful mostly when the statements are expressions.
Commands and directives should not be stacked like that, for readability (such commands are often long lines already) and for compatibility (lot of these commands want a naked string as last parameter, so it is hard to tell where the command ends and where the new one starts).
So perhaps by introducing some new expression operator, it is possible to allow this.
There are not so much symbols still available...
Perhaps one making sense is colon, hopefully requesting it to be surrounded by spaces (like concatenation operator).
a := 1 : b := a * Fun(z) : x := (a + b) / (a - b)
x := FindOutXParam()   :     y := FindOutYParam()    :     z:= (x + y)/2
Well, strictly speaking, even semi-colon can be used as this, as long as it is mandatory to stick it on the last char of the expression (ie. no space before it!). It would have a familiar look for the programmers out there, but I fear it will be confusing for the newbies, and we have already enough sources of confusion to take care...

Beside, I agree with Chris, ie. we can live without it.
We can do whatever we want even without sentence delimiter, while some other features are dearly needed to do some things.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
I don't like the idea of semicolon as it looks very strange....
; is the only simbol, besides , that is not consuming space and feels natural in scenarios like this one.

I hope for this for v2 as this is big update and thus deserves to be introduces with bunch of other things.

Anyway, I created small preprocessor for this, here.

Not only expressions are problematic, but ifs also

if (something) do_something is much more natural

I vote comment symbol changed from ; to // and reserve ; to something else. It was a bad choice originaly anyway, and it should be "fixed" in v2.
Posted Image

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks for the comments. I like PhiLho's idea of extending expressions with a new multi-statement operator because not only would it be much easier to implement than changing the load-time parser, it would also allow assignments inside an expression (which Titan and others have asked for).

However, changing the comment flag from ; to // might be more trouble than it's worth to everyone. If anyone is interested, please set up a poll for choosing between //, semicolon, and/or others. Update: The poll has been created at http://www.autohotke...pic.php?t=13950

If the comment flag isn't changed, I think a comma might be the ideal statement separator inside expressions -- assuming it doesn't cause too much ambiguity with function-call parameters.

Thanks.

Edit: Support for comma-separated expressions has been added in v1.0.46. This allows a single line to contain multiple assignments, function calls, and other expressions.

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
I like the comma too. And rather than ambiguity, it might actually make things simpler for those with less experience.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I don't like the idea of semicolon as it looks very strange....
; is the only simbol

You meant colon, not semi-colon.
; is not the "only" symbol, AFAIK, : is used in Basic.
But I acknowledge that it is the most used symbol, present in numerous languages.

I vote comment symbol changed from ; to // and reserve ; to something else. It was a bad choice originaly anyway, and it should be "fixed" in v2.

Why a bad choice? It has been made by AutoIt 2 author which made a simple, rustic language, like .bat files. This symbol is a comment in Rebol, assembly languages (ASM), .ini files, .reg files (which are a variant of .ini, indeed), CSound, Kix, Nsis, perhaps still in AutoIt 3.
And // isn't the only symbol for comments, we find frequently # or --, for example.
I don't feel the need to change this symbol, it can even coexist as separator, as long as there is no space before it.

[EDIT] Meanwhile, Chris answered... Well, the comma seems like a good idea, as it is not used in expressions, and already used as parameter separator in commands, so it keeps its special meaning.
It should not be ambiguous with function parameters. Seems OK, and close to the semi-colon that some want.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

Why a bad choice?

Never heard for Rebol. ASM is not very representative example.
INI & REG files are not the languages at all. CSound is DSP language with huge boxes and it doesn't make sense to use more on the same line as almost every command has more then 10 parameters some of them 20, 30 and son on... The same applies to REG and INI files.

The problem is that with AHK it originaly wasn't recognised as multi purpose language witch it appears to be now. People do all kind of thing in it, and most of them are not about automatition, just scan the scripts section. And real language needs multiple statements on the same line as possibility.


I am not forcing // instead ; as comments. I am really interested in ; becoming separator for commands in v2 as comma is much more problematic (it is used to delimit parameters now).

About comment charachter it can be whatever - #, -- ' ...

If nothing else, : will do the thing :D.
But I don't think it is smart to typical users. It is devide operation in math, so n00bs may think that it is part of expression.

BTW, I created ISense to be able to use it with CSound. Granulalr synthesis object, the one that use so called atoms of sound has around 30 parameters....
Posted Image

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

If nothing else, : will do the thing :D.
But I don't think it is smart to typical users. It is devide operation in math, so n00bs may think that it is part of expression.

I agree! Looking at the sample line I gave, I found it confusing, even if it is better with multiple spaces around...
So it is either ; or ,
Note it can be \ too, it is unused... ;-)

FYI, Rebol is a private language (freeware in its base version, but closed source) which is widely used for scripts dealing with network in general and more specifically with Internet. Network support is built in the language.
It is interesting, has good GUI support, lightweight, but proprietary and its syntax is... disturbing. Mostly because I didn't looked deep in the manuals,yet it isn't so intuitive.
; some preliminary helper functions

quoted?: func [string [string! file! url!]] [
    either all [(first string) = #"^"" (last string) =  #"^""] 
        [true]
        [false]
]
quote: func [string [string! file!]] [insert string "^"" append string  "^""]
unquote: func [string [string! file!]] [remove string string: skip string ((length? string) - 1) remove string head string]

; ini file functions and defaults

inifile: %data.ini
inifilebak: append copy inifile ".bak"
backup-ini: does [
                            if exists? inifilebak [delete inifilebak]
                            rename inifile inifilebak
                    ]
; [...]    
        ]

; serialization

proto-log: make object! [
                title: path: down: rate: none
]

initialize: does [
    
; [...]    
    
    ; what if inifile is empty or contains invalid characters for blocks?
    if any [error? data: try [to-block read inifile] empty? data][
        backup-ini 
        write inifile data {readme "readme.txt" 0 1}
        if not exists? %readme.txt [write %readme.txt system/script/header/readme]
        data: to-block read inifile
        ] 
; [...]    
    logs: make block! ((length? data) / 4) 
    forskip data 4 [
            object: make proto-log [
            title: to-string first data
            original: second data
            path: switch type?/word original [block! [do load original] string! [to-rebol-file either quoted? copy original [unquote copy original] [copy original]] url! [to-rebol-file to-string original]]
            down: to-logic third data
            rate: fourth data
            ]
        append logs object
    ]   

    ; prepare block of data for data list, alternatively, use 'supply with 'list

    bl: make block! (length? logs)
    forall logs [append bl form get in first logs 'title]
    logs: head logs
    bl: head bl
]

initialize

it doesn't make sense to use more on the same line as almost every command has more then 10 parameters

Well, that's what AutoIt 2 and early AutoHotkey was... ;-)

The problem is that with AHK it originaly wasn't recognised as multi purpose language witch it appears to be now. People do all kind of thing in it, and most of them are not about automatition

I must agree... Even stuff on the edge of automation, like my TrueType file information library, which was made for Goyyah which needed to automate installation of fonts, go beyond simple automation. Still on focus but more complex.
And BBCodeEdit or games made with AHK are clearly outside this field. Give a spoon to a creative user, he will use it to make a Statue of Liberty out of a block of ice... Not made for this, but usable... ;-)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
Oh.. another syntax... no good words for that...
I wish esperanto was not just a waste of time...
Posted Image

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
:-D You (might) have not seen Eiffel, Erlang, Haskell, Scheme, ML, Forth, PostScript, Pike, APL, Squeak, Prolog, Icon, etc. To name but a few I looked at. There are hundred or thousand of more or less exotic languages, lot of them in niche uses... Some of them introduce new ways of programming, like functional programming or logic programming. Interesting, but forces to think differently.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
For the sake of coherence, it would be nice if we posted about the comment issue in this topic now. It's important enough to have its own separate discussion, and there's some interesting and relevant things being said here.

Thankya. 8)

majkinetor !
  • Guests
  • Last active:
  • Joined: --
I know Prolog and Lisp :D