• 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: Coercing strings to symbols
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coercing strings to symbols


  • Subject: Re: Coercing strings to symbols
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 15 Feb 2008 17:59:40 -0500

On Fri, Feb 15, 2008 at 3:18 PM, has <email@hidden> wrote:
>  I assume you mean 'constants', to use AppleScript's somewhat confusing
>  parlance. (Other languages use the proper terms 'enumerators' and
>  'enumerations'/'enumerated types'.)

They are nevertheless constants, which is a fine thing to call them.
Nothing confusing about it.

> Longer answer: this sort of thing is trivial in other, more
>  capable languages such as Python, Ruby and ObjC, e.g.:
>
>         #!/usr/bin/env ruby
>
>         string = "center"
>         symbol = string.intern
>
>         p symbol
>         # :center

 Bogus example.  Sure, if you were designing an API natively in Ruby
and you had to represent a list of possible values, symbols would be a
logical choice.  But in general you still have the problem of names vs
strings where the value of the name is not simply the interned version
of the string.  For instance, the value of Socket::SOCK_DGRAM (which
is called a "constant" in the library doc, btw) is 2, not :SOCK_DGRAM.

It's true that languages like Ruby make it easier to do the
string->other decoding, since you can use a hash table instead of
conditional branches, but the ability to intern symbols doesn't enter
into it.

--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Coercing strings to symbols
      • From: has <email@hidden>
    • Re: Coercing strings to symbols
      • From: "Houston, Brad" <email@hidden>
References: 
 >Coercing strings to symbols (From: "Houston, Brad" <email@hidden>)
 >Re: Coercing strings to symbols (From: has <email@hidden>)

  • Prev by Date: Re: Sound Effects
  • Next by Date: Re: Run AppleScript in the background (hide window)
  • Previous by thread: Re: Coercing strings to symbols
  • Next by thread: Re: Coercing strings to symbols
  • Index(es):
    • Date
    • Thread