[#363639] Parsing geonames — 12 34 <rubyforum@...>

A Ruby newbie having trouble getting results back from geonames

16 messages 2010/06/02
[#363641] Re: Parsing geonames — Michael Fellinger <m.fellinger@...> 2010/06/02

On Wed, Jun 2, 2010 at 2:57 PM, 12 34 <rubyforum@web.knobby.ws> wrote:

[#363642] Re: Parsing geonames — 12 34 <rubyforum@...> 2010/06/02

Michael Fellinger wrote:

[#363646] installation issue with Ruby gems on Ubuntu 8.04 — Santosh Dvn <santoshdvn@...>

Hi I am installing ruby gems on ubuntu 8.04 .. while installing i got

14 messages 2010/06/02

[#363662] having a class method called only one time ? — unbewusst.sein@... (Une B騅ue)

I'd like having a class method called only one time ?

12 messages 2010/06/02

[#363756] comparing objects — Anderson Leite <andersonlfl@...>

How can I compare two objects and get true if some of his atributes are

48 messages 2010/06/03
[#364122] Re: comparing objects — Rein Henrichs <reinh@...> 2010/06/10

On 2010-06-10 06:59:40 -0700, Robert Dober said:

[#363764] Documenting Ruby 1.9: Ebook or Wiki? — Run Paint Run Run <runrun@...>

I'm writing a free ebook about Ruby 1.9 at http://ruby.runpaint.org/ .

17 messages 2010/06/04
[#363765] Re: Documenting Ruby 1.9: Ebook or Wiki? — Mohit Sindhwani <mo_mail@...> 2010/06/04

On 4/6/2010 11:30 AM, Run Paint Run Run wrote:

[#363775] Looking for ORM for 'legacy' database. — Dave Howell <groups.2009a@...>

I feel I should start with some pre-emptive apologies. I used to subscribe to this list, but haven't been reading it for a year or so, so I may have missed the answer to my question. (I did try finding it in the list archives, of course.) Also, I'm a little frustrated, and that might adversely influence the tone of this message. I'll try to avoid that, but I beg your forgiveness if I sound a little snide.

28 messages 2010/06/04
[#363895] Re: Looking for ORM for 'legacy' database. — Phrogz <phrogz@...> 2010/06/06

On Jun 4, 3:29m, Dave Howell <groups.20...@grandfenwick.net> wrote:

[#363975] Re: Looking for ORM for 'legacy' database. — Dave Howell <groups.2009a@...> 2010/06/07

[#363883] inject method of Array class — RichardSchollar <richardgschollar@...>

I have only just started using Ruby (and am a total noob, in case this

14 messages 2010/06/06

[#363944] Complex numbers contradiction? — Andrew Duncan <andrew.duncan@...>

This looks correct:

13 messages 2010/06/07
[#363951] Re: Complex numbers contradiction? — Robert Dober <robert.dober@...> 2010/06/07

On Mon, Jun 7, 2010 at 9:01 PM, Andrew Duncan <andrew.duncan@sonos.com> wrote:

[#364010] Rubyzip - `dup': can't dup NilClass (TypeError) — Luka Stolyarov <lukich@...>

Hello. I've trying to figure out rubyzip. Here's the code I had:

11 messages 2010/06/08

[#364101] Why private #binding? — Intransition <transfire@...>

Why is #binding a private method? I end up doing a lot of this:

13 messages 2010/06/10

[#364268] State of the union for Ruby CLI libraries? — John Feminella <johnf@...>

I am starting construction on a somewhat complicated internal

18 messages 2010/06/13

[#364273] Loading a module without polluting my namespace — Hagbard Celine <sin3141592@...>

Hey folks!

20 messages 2010/06/13

[#364330] shorthand — Roger Pack <rogerpack2005@...>

I read this once:

14 messages 2010/06/14

[#364342] Placement of require() and missing symbols — Eric MSP Veith <eveith@...>

-----BEGIN PGP SIGNED MESSAGE-----

16 messages 2010/06/15
[#364365] Re: Placement of require() and missing symbols — Kirk Haines <wyhaines@...> 2010/06/15

On Mon, Jun 14, 2010 at 7:18 PM, Eric MSP Veith

[#364371] datamapper blues — Martin DeMello <martindemello@...>

I'm investigating the use of DataMapper to convert an old project with

14 messages 2010/06/15

[#364402] Getting rid of self — Ralph Shnelvar <ralphs@...32.com>

22 messages 2010/06/16
[#364440] Re: Getting rid of self — Josh Cheek <josh.cheek@...> 2010/06/16

On Wed, Jun 16, 2010 at 4:31 AM, Ralph Shnelvar <ralphs@dos32.com> wrote:

[#364415] Android apps using ruby — Lakshmanan Muthukrishnan <lakshmanan@...>

Hi,

16 messages 2010/06/16
[#364439] Re: Android apps using ruby — Andrew Kaspick <akaspick@...> 2010/06/16

Lakshmanan Muthukrishnan wrote:

[#364479] Re: Android apps using ruby — Lakshmanan Muthukrishnan <lakshmanan@...> 2010/06/17

Andrew Kaspick wrote:

[#364496] nothing new in ruby_core for four days ? — Michel Demazure <michel@...>

The Ruby Core forum has no new entry since four days ago.

15 messages 2010/06/17
[#364498] Re: nothing new in ruby_core for four days ? — Brian Candler <b.candler@...> 2010/06/17

Michel Demazure wrote:

[#364529] Dear gem: still no zlib. — Dave Howell <groups.2009a@...>

I really really regret ever installing SnowLeopard.

16 messages 2010/06/17

[#364580] String comparison. Why does Ruby consider this true? — Abder-rahman Ali <abder.rahman.ali@...>

When I try for example to compare the following strings in Ruby, I get

13 messages 2010/06/18
[#364584] Re: String comparison. Why does Ruby consider this true? — Josh Cheek <josh.cheek@...> 2010/06/18

On Fri, Jun 18, 2010 at 12:46 PM, Abder-rahman Ali <

[#364628] Random Points within a Circle (#234) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

21 messages 2010/06/19
[#364696] Re: [QUIZ] Random Points within a Circle (#234) — Caleb Clausen <vikkous@...> 2010/06/21

On 6/19/10, Daniel Moore <yahivin@gmail.com> wrote:

[#364641] Namespacing a class — Eric MSP Veith <eveith@...>

-----BEGIN PGP SIGNED MESSAGE-----

18 messages 2010/06/20

[#364815] Count substrings in string, scan too slow — Danny Challis <dannychallis@...>

Hello everyone,

18 messages 2010/06/24
[#364817] Re: Count substrings in string, scan too slow — Jes俍 Gabriel y Gal疣 <jgabrielygalan@...> 2010/06/24

On Thu, Jun 24, 2010 at 5:04 PM, Danny Challis <dannychallis@gmail.com> wrote:

[#364825] Re: Count substrings in string, scan too slow — Robert Klemme <shortcutter@...> 2010/06/24

2010/6/24 Jes俍 Gabriel y Gal疣 <jgabrielygalan@gmail.com>:

[#364850] Happy Intransition Day! — Ryan Davis <ryand-ruby@...>

Happy Intransition Day!

23 messages 2010/06/24

[#364930] Ruby in JavaScript, all projects are dead? — Alexey Petrushin <axyd80@...>

Hello, recently I've examined some of the projects that trying to bring

18 messages 2010/06/27

[#364988] Reading String Data as a File — Doug Jolley <ddjolley@...>

I use Net::HTTP to collect some data as a string. I now need to pass

25 messages 2010/06/29
[#364989] Re: Reading String Data as a File — Ryan Davis <ryand-ruby@...> 2010/06/29

[#364996] Re: Reading String Data as a File — Brian Candler <b.candler@...> 2010/06/29

Ryan Davis wrote:

[#365016] Re: Reading String Data as a File — Doug Jolley <ddjolley@...> 2010/06/29

> If it takes only a pathname argument, then you're

[#365024] Re: Reading String Data as a File — Tony Arcieri <tony.arcieri@...> 2010/06/29

On Tue, Jun 29, 2010 at 11:50 AM, Doug Jolley <ddjolley@gmail.com> wrote:

[#365036] Re: Reading String Data as a File — Robert Klemme <shortcutter@...> 2010/06/30

2010/6/29 Tony Arcieri <tony.arcieri@medioh.com>:

[#365049] Re: Reading String Data as a File — Brian Candler <b.candler@...> 2010/06/30

Robert Klemme wrote:

[#365039] pathname.rb:270: warning: `*' interpreted as argument prefix — "R.. Kumar 1.9.1 OSX" <sentinel1879@...>

/opt/local/lib/ruby1.9/1.9.1/pathname.rb:270: warning: `*' interpreted

12 messages 2010/06/30
[#365048] Re: pathname.rb:270: warning: `*' interpreted as argument prefix — Josh Cheek <josh.cheek@...> 2010/06/30

On Wed, Jun 30, 2010 at 6:11 AM, R.. Kumar 1.9.1 OSX <sentinel1879@gmail.com

Re: Namespacing a class

From: Robert Klemme <shortcutter@...>
Date: 2010-06-25 12:30:05 UTC
List: ruby-talk #364879
2010/6/25 Intransition <transfire@gmail.com>:
> On Jun 24, 11:58m, Robert Klemme <shortcut...@googlemail.com> wrote:
>
>> I don't understand what you mean here. an you elaborate or provide an example?
>
>
> # lib/foo/baz.rb
>
> class Foo::Baz
> ..
> end
>
>
> # lib/foo.rb
>
> require 'foo/baz'
>
> class Foo
> ..
> end

I always thought the proper idiom was

# lib/foo.rb

class Foo
 ...
end

# optionally:
require 'foo/baz'


# lib/foo/baz.rb

require 'foo'

class Foo::Baz
 ...
end


Alternative:

# lib/foo.rb

class Foo
 ...
  autoload :Baz, 'foo/baz'
end

# lib/foo/baz.rb
(as above)

>> > 2) The developer is forced to choose between two arbitrarily limited
>> > mechanisms for modeling behavior. Classes can only re-used once per
>> > subclass and not at all via modules. Modules can be reused extensively
>> > but do not naturally include their singleton methods. These
>> > limitations lead to a number of code smells from overly limited use of
>> > inheritance to included/ClassMethods hooks.
>>
>> Why is not including their singleton methods a strong limitation?
>
> Well it is strong.

That's a strange answer to my question...

> In fact, if it wasn't for that, the difference be
> almost ephemeral. But strong != good. I know that matz has cited this
> issue in the past, but I have never seen an explanation of why it is
> so bad to get the module singleton methods? Clearly in many cases that
> is exactly what people want, which is why they ClassMethods hack is so
> common.

Let my first try to understand what you mean.  If I get you properly you want

module A
  def self.wok
    puts "I work for the class"
  end

  def foo
    puts "happy instance"
    self.class.wok
  end
end

class X
  include A
end

X.new.foo ->
"happy instance"
"I work for the class"

I personally would write

  def foo
    puts "happy instance"
    A.wok
  end

and be done so I suspect you mean something else.

> If it were the other way around, and the singleton methods
> were passed along, but you didn't want them to be... well I would like
> to know under what circumstances that it would really be a problem. If
> those singleton methods were simply being used as functions (M.f) then
> they can easily be placed in a separate module. If they were being
> used as a DSL for the module itself, why would the including class be
> any worse off by gaining the DSL too? aybe there is some reason one
> can find, but even so it seems to me that it must be the rarity.

If I get your drift you want to use a single module to define a DSL
and apply it at the same time, e.g.

module DSL
  def self.smart_attribute(sym)
    class_eval "def #{sym}; puts 'Look Ma, how smart I am!'; @#{sym}; end"
  end

  smart_attribute :name
end

and then

class Foo
  include DSL

  smart_attribute :age
end

f = Foo.new
f.name
f.age

I personally would separate the DSL out into another module because
that is more modular.  Not all classes might need smart attribute
"name" so this would be a better choice IMHO.

> In
> all my use of modules I can't think of case where having the singleton
> level would have been a problem and in many, if not most, I actually
> wanted it and had to resort to some hoop jumping.
>
> In fact, and I think this is worth pointing out... I never ever design
> a module to be utilized via #extend. In such usecases I actually do
> this:
>
> odule M
> ef self.append_features(base)
> ase.extend self
> nd
> nd
>
> Of course, rather than fuss about it, we could also have the best of
> both worlds (imagine that). , for one, would be happy with a new
> method to go along with #include and #extend that provided both
> singleton and instance levels.

I believe automatically propagating class methods might cause
confusion because it is not obvious. At least I haven't had the need
for this (which might be due to the different tasks we tackle with
Ruby).

>> > 3) Using tools for conceptually different cases does not require that
>> > their be physically different tools for each case. I wrench is just as
>> > good for tightening a nut as it is for loosening one. If I had to use
>> > two separate tools it would be quite annoying.
>>
>> I believe this is a bad analogy. f at all you would have to take
>> "tightening and loosing nuts" and "hammering". n that case it's
>> quite obvious that you would not normally use the same tool for the
>> job.
>
> Maybe so. But a class is a subclass of module. So they are very
> similar tools, unlike a hammer and a wrench. My point was simply that,
> as craftsman, we'd rather have just one tool, if it can do the job two
> just as well.
>
>> > Following your conceptual distinction argument we could just as easily
>> > argue for separate entities for mixins and namespaces ince those are
>> > also different uses of modules. Clearly no one wants that.
>>
>> Actually I thought about mentioning this because namespacing is yet
>> another concept which happens to have two tools - module and class.
>> It probably feels very natural because all major OO languages do
>> support this. nd it does have some merits.
>>
>> > I have never heard of a solid reason for the division between classes
>> > and modules --my guess is that there is no real reason other than that
>> > it how it was done originally, and changing it now means 1) a major
>> > version bump and 2) an overhaul of the implementation.
>>
>> I find that distinction pretty clear as I have tried to point out
>> earlier. omehow you seem to be using the language quite differently
>> than me and have run into limitations that do not exist for me. aybe
>> we can take the discussion a bit further to find out more about this.
>
> Perhaps b/c I have done a lot of meta-programming? Not sure. It would
> be interesting to know more, I agree.

I believe this points into the right direction.  I'm not doing as much
meta programming - probably because I am not involved in creating
frameworks in Ruby.  I rather use the language to solve day to day
problems.  So far my need for DSL's has been scarce.  So where were
you really hurt by not automatically propagating class methods?  I
can't think of a case but obviously you have one in mind.

Thanks for the discussion!

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

In This Thread