Does ":" have an anolog in another language?

. . . except that doesn't point out the object-orientedness of it. The
reason I brought up attaching something related to object oriented
programming to the word "symbol" was as a means of contrasting with an
older and, in many cases, better-known use of "symbols" in programming
(a use that is, in fact, almost identical except for that pesky OO-ness
of Ruby).

···

On Sat, Jul 29, 2006 at 05:11:35AM +0900, ara.t.howard@noaa.gov wrote:

On Sat, 29 Jul 2006 dblack@wobblini.net wrote:

>I'd just call them symbols, or Symbol objects (just as with strings,
>arrays,
>etc.).

i like 'symbol literal' as in

  array literal => [42]
  hash literal => {42=>42}
  symbol literal => :foo

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"A script is what you give the actors. A program
is what you give the audience." - Larry Wall

In my example, using a symbol would be the same as creating a symbol
object (whose initialize() method was overwritten to pull a
Unique-Singleton deal):

{ :foo => "bar" }

is the same as

{ Symbol.new('foo') => "bar" }

(That is, if Symbol had #new defined).

It's like saying...

"Hello"

does the same thing as

String.new('hello')

except that it doesn't create a new object for duplicate values, it
simply returns the reference to the previous Symbol object created.

M.T.

Hi --

···

On Sat, 29 Jul 2006, Matt Todd wrote:

In my example, using a symbol would be the same as creating a symbol
object (whose initialize() method was overwritten to pull a
Unique-Singleton deal):

{ :foo => "bar" }

is the same as

{ Symbol.new('foo') => "bar" }

(That is, if Symbol had #new defined).

It's like saying...

"Hello"

does the same thing as

String.new('hello')

except that it doesn't create a new object for duplicate values, it
simply returns the reference to the previous Symbol object created.

Sorry, I'm not following. What purpose would the hypothetical
Symbol.new serve?

David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
Ruby for Rails => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.

Really as an example of its objectness. It's a way to look at the
literal (:symbol_name) as the same as an instanciation, but with
conditions (of uniqueness).

I'm just sharing how I look at it.

M.T.

Hi --

···

On Sat, 29 Jul 2006, Matt Todd wrote:

Really as an example of its objectness. It's a way to look at the
literal (:symbol_name) as the same as an instanciation, but with
conditions (of uniqueness).

You might as well save the round trip, though :slight_smile: It's in the same
category as integers: unique and immediate, as well as immutable.

David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
Ruby for Rails => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.

Indeed. I understand that, just trying to illustrate it to those
familiar with objects moreso than symbols, atoms, or whatever they are
called. :slight_smile:

@Keith: thanks for that bit on Prolog.

So far, I think we've gotten a pretty good understanding of symbols,
regardless of how we choose to represent it in our mind.

:slight_smile:

M.T.

dblack@wobblini.net wrote:

Hi --

Really as an example of its objectness. It's a way to look at the
literal (:symbol_name) as the same as an instanciation, but with
conditions (of uniqueness).

You might as well save the round trip, though :slight_smile: It's in the same
category as integers: unique and immediate, as well as immutable.

David

The most salient symbol example for me has always been:

> irb --simple-prompt
>> "foo".object_id
=> 23208408
>> "foo".object_id
=> 23205828
>> :foo.object_id
=> 5896462
>> :foo.object_id
=> 5896462

Tom

···

On Sat, 29 Jul 2006, Matt Todd wrote:

--
Tom Werner
Helmets to Hardhats
Software Developer
tom@helmetstohardhats.org
www.helmetstohardhats.org

Hi --

···

On Sat, 29 Jul 2006, Matt Todd wrote:

Indeed. I understand that, just trying to illustrate it to those
familiar with objects moreso than symbols, atoms, or whatever they are
called. :slight_smile:

I see what you mean. Symbols do seem to present problems -- they're
sort of string-like, sort of identifier-like, sort of integer-like...
yet not exactly like any of those.

David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
Ruby for Rails => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.