• 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: "Houston, Brad" <email@hidden>
  • Date: Fri, 15 Feb 2008 16:31:23 -0800
  • Thread-topic: Coercing strings to symbols

Thanks to you all. I much prefer knowing that something isn't doable than
just wondering if I'm wasting your time looking or foolishly plunging ahead
with a bad method. Onward with the if..then stacks.

Brad


On 2/15/08 2:59 PM, "Mark J. Reed" <email@hidden> wrote:

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

References: 
 >Re: Coercing strings to symbols (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Broken date math on AppleScript 2.0
  • Next by Date: make new custom tag in Aperture 2.0
  • Previous by thread: Re: Coercing strings to symbols
  • Next by thread: Re: Coercing strings to symbols
  • Index(es):
    • Date
    • Thread