Re: Scripting Style (was: Re: Hiding Slaves)
Re: Scripting Style (was: Re: Hiding Slaves)
- Subject: Re: Scripting Style (was: Re: Hiding Slaves)
- From: email@hidden (Michael Sullivan)
- Date: Sat, 14 Sep 2002 23:01:08 -0400
- Organization: Society for the Incurably Pompous
Paul Berkowitz writes:
>
> 'As string' is entirely unambiguous, dirt simple to read and understand.
>
> That empty string concatenation is not (as Ken's post has just
>
> demonstrated). It's just bad programming. [2]
>
It's not bad programming, since the ASLG gives it as a valid method.
The C standard gives "goto" as a valid command. That doesn't mean you
should use it. It's only there at this point to support legacy code
(Not sure why it was there in the first place, except maybe before _GoTo
Considered Harmful_, no one would take your language seriously if it
didn't have it).
>
It's in
>
there - go check. They happen to use longer strings than "", but it's the
>
same method. It certainly is not as clear or easy to read when used as an
>
educative tool, as this mailing is. I actually moved over to 'as string'
>
myself about a year and a half ago, since I'd rather be clear than a party
>
to 'deliberate obfuscation', etc. also - why not be more efficient, even for
>
1/10,000th of a second? Nevertheless, Applescript gives many ways of doing
>
things, and that one is valid and works.
When there are two ways of programming something and one is more clear,
always prefer the one that is more clear, unless there is a specific
advantage to using the less clear version. Back when appending
something to the empty string was faster than an explicit coercion, this
wasn't necessarily bad programming. Now that there it's actually
*slower*, it is, since it reduces clarity to no other advantage.
That said, it's a fairly minor point, as most folks on seeing that code,
will understand what it is doing, and what it is supposed to produce,
even if the implicit coercion is not obvious to them.
>
>> property u : ("" as Unicode text)
>
>> set hidFolderPath to ((u & (path to scripts folder)) & ".hid")
>
> First person to do this, I kill just on General Principles.
>
> You've been warned. ;)
>
What i do all the time is
>
property lf : (ASCII character 10)
That's different. For one thing 'lf' (or better yet, 'linefeed') is far
clearer to the casual reader than "ASCII character 10"
For another, there is a real, and significant speed gain from this if
you end up using that lf character more than a few times, so even if it
were less clear, that might be offset.
Michael
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.