• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Labeled parameter bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Labeled parameter bug


  • Subject: Re: Labeled parameter bug
  • From: has <email@hidden>
  • Date: Sun, 10 Mar 2002 10:02:02 +0000

Anthony Adachi wrote:

>There appears to be a bug in Mac OS 9.1 and AppleScript 1.6 with labeled
>parameter handler calls.

I remember running across a bug or three in AS1.3.7 as well. After
exploring AS's labelled params for a day or two I concluded that they were
unreliable, and mostly worthless too.

I also find code that uses them to be harder to read, and sometimes
downright painful, as it tries to make logical-sounds sentences through a
combination of convoluted variable names interspersed by a few fairly
useless keywords.

I've stuck with positional parameters since, and they work just fine. But,
hey, I've already ranted before on this issue, so I won't bother doing it
again.


BTW, if you do truly need "optional parameters", wrap your 'parameters' in
a record before passing them to a handler like so:

doSomething({param1:someValue, param2:anotherValue})

on doSomething(paramsRec)
set param1 to paramsRec's param1
set param2 to paramsRec's param2

--do stuff with local vars param1 & param2

end doSomething


and to make one or more of those params optional:

set param1 to paramsRec's param1 & {param1:"some default value"}

I don't recommend this for regular use though, as it bloats and slows your
code and makes it harder to read.

--

Anyway, thanks for pointing out another reason why labelled parameters suck
in AppleScript. I tried your script under AS1.3.7 and it gave the same
problems there, so it's clearly a longstanding bug. But like I say I'd be
much happier if the AS team would ditch that old junk and implement a
decent system instead (e.g. see python), rather than try to patch up
something that sucks anyway.

Cheers,

has
_______________________________________________
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.

  • Prev by Date: Styled Text Library - Getting RGB from style data
  • Next by Date: Re: Script to reboot from X into 9
  • Previous by thread: Re: Styled Text Library - Getting RGB from style data
  • Next by thread: Do shell script "date" vs current date
  • Index(es):
    • Date
    • Thread