"Gtk::Window#show" notation

R

Robert Plantz

I am reading the tutorial in Ruby-gnome2 and I see:

"The third line calls Gtk::Window#show to display the window we just
created:"

to describe:

"window.show"

Please excuse my ignorance, but I do not know the use of the '#'
character here. I've searched around quite a bit. I see the syntax is
commonly used, but I cannot locate an explanation of it. The only
explanation I see for the '#' character is that everything following is
a comment.

Can someone point me to documentation that describes the use of '#'
other than as the comment character? Or perhaps tell me what I should
have read before this tutorial?
 
D

David Vallner

--------------enig1FBF36F7B625C450E143CA61
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Robert said:
Can someone point me to documentation that describes the use of '#'=20
other than as the comment character? Or perhaps tell me what I should=20
have read before this tutorial?
=20

This is a convention. GtkWindow#show means "instance method 'show' in
the class GtkWindow". I've seen it used heavily in Smalltalk-related
material, though the last time this topic came up (a year or so back?),
someone came up with a more detailed "etymology". I'd tell you to check
the mailing list archives, except I've no idea myself what I'd begin to
search for...

David Vallner


--------------enig1FBF36F7B625C450E143CA61
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFO/5uy6MhrS8astoRAilZAJ4xqLSL5NgLJa80NsCxeiqm5htGwwCffeDI
6EsFgzsxDOBKuc0IzE8oCmg=
=vdJa
-----END PGP SIGNATURE-----

--------------enig1FBF36F7B625C450E143CA61--
 
K

Ken Bloom

This is a convention. GtkWindow#show means "instance method 'show' in
the class GtkWindow". I've seen it used heavily in Smalltalk-related
material, though the last time this topic came up (a year or so back?),
someone came up with a more detailed "etymology". I'd tell you to check
the mailing list archives, except I've no idea myself what I'd begin to
search for...

Note that ri accepts this notation to refer to a class name when you're
asking for documentation (you may need to quote the whole thing in your
shell), but there is NO part of the Ruby language that accepts this
notation, nor do I really see much need.

To get an UnboundMethod object referring to the instance method 'show' in
the class 'GtkWindow', you use the code GtkWindow.instance_method:)show)
since the need for that in actual code pretty uncommon to begin with,
there's no reall need for more concise notation.

--Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top