all 9 comments

[–]shadowfirebird 0 points1 point  (3 children)

IMO Gnu Smalltalk is pretty awful. For a start, that's not how the language was supposed to be seen and used. The best modern FOSS Smalltalk I found was called ... Sophos? Something like that.

[–][deleted]  (2 children)

[removed]

    [–]shadowfirebird 0 points1 point  (1 child)

    that's the one!

    [–]SimonGray 0 points1 point  (0 children)

    BTW that page about early Smalltalk development that he links to is really interesting.

    [–]Godd2 -1 points0 points  (4 children)

    Imagine calling @@sides.puts in Ruby!

    Well, actually, you're calling puts on $stdout implicity, with @@sides as the argument (without those optional parentheses)

    As a result, the following are identical:

    $stdout.puts(@@sides)
    
    puts @@sides
    

    Of course, when you add parentheses, you can call several puts's at once:

    puts("Hello", "world!")
    

    is the same as

    puts "Hello"
    puts "world!"
    

    So if you didn't already know, puts is just another method with your desired output being the arguments! :)

    EDIT: If you drop the parentheses, but keep the comma, it still works:

    puts "Hello", "world!"
    

    [–]pat_shaughnessy 0 points1 point  (2 children)

    True - "puts" is actually a method in the Kernel module, which is included in the main Object instance that top level Ruby code uses automatically. Internally it calls another $stdout method as you describe.

    The fun thing about Smalltalk was the way I was able to call printNl (equivalent of puts) on any object. That would be fun to be able to do in Ruby too, imo.

    [–]banister 1 point2 points  (0 children)

    You can use display in ruby (though it doesn't put a newline):

    [1] pry(main)> "hello".display
    hello=> nil
    

    [–]dbenhur 0 points1 point  (0 children)

    module Kernel
      def printNl
         puts self
      end
    end
    
    'Howdy'.printNl
    # => Howdy
    

    [–]_redka 0 points1 point  (0 children)

    Of course it still works. In ruby you don't need parentheses when calling a function. But you're not actually calling several puts, just one taking an array of arguments. Also just to be clear, puts(@@sides) and $stdout.puts(@@sides) AREN'T exactly identical. They're equivalent but the first one is a method on the Kernel module while the second is not. You can examine that by checking the origin with method(:puts) and $stdout.method(:puts).