mineiro has quit [Read error: Connection reset by peer]
<judofyr>
just explaining the stack effect
<erikh>
manveru: I think so, but I haven't beaten it yet
<erikh>
I bought it two days ago
mineiro has joined #ruby-lang
<whitequark>
judofyr: er... where is dem runtime
<judofyr>
whitequark: what runtime?
<whitequark>
oh I see, two.rb
<judofyr>
ah
<judofyr>
whitequark: now that you're reading the code: yes, I lied, it does have one mutable construct: the main environment.
<judofyr>
whitequark: but it's easier that way (so :foo bar ; :bar ;) will work nicely
<judofyr>
whitequark: once again: I don't think there's much novelty in this language (yet). it's basically Joy with method dispatch on the element on the top of the stack. pretty similar to Factor.
<judofyr>
but it was nice when I spent a few hours writing map/fold/filter/wrap/concat yesterday without having an interpreter, and when I wrote the interpreter today they ran perfectly \o/
<whitequark>
all hail puzzle languages
<judofyr>
maybe I'll investigate (1) how to add concurrency (actor model perhaps?) or (2) full-program optimizer
<whitequark>
judofyr: your language is excellent when it comes to studying optimizations
<whitequark>
...
<whitequark>
well, in the sense that applying optimizations to it is damn easy
<judofyr>
yup
<whitequark>
or, that it doesn't represent most real-world challenges :D
<judofyr>
and some stack effect: if (cond [T] [F] -- ), uncons ( list -- head tail ), cons ( head tail -- list )
<injekt>
D:
workmad3 has quit [Read error: Operation timed out]
<judofyr>
( head tail -- list ) means that the stack will have the head and tail before (where tail = top of stack) and it will leave a list on the stack
<judofyr>
oh, and: null ( list -- bool )
<judofyr>
so it's very similar to Lisp's map
<judofyr>
first check if it's an empty list
<judofyr>
if not, it splits it up (using uncons), ignores the current top of the stack (that is, the tail), uses square to square the head, recurses, and combines it again
mistym has quit [Remote host closed the connection]
<judofyr>
ddfreyne: it's pretty amazing
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
<judofyr>
æ ø å
retro|cz has quit [Ping timeout: 252 seconds]
mineiro has quit [Read error: Connection reset by peer]
marr has joined #ruby-lang
mineiro has joined #ruby-lang
vlad_starkov has joined #ruby-lang
jbar has quit [Remote host closed the connection]
rgn has quit [Read error: Operation timed out]
Squarepy has joined #ruby-lang
benlovell has quit [Ping timeout: 264 seconds]
patrickod has left #ruby-lang ["Textual IRC Client: www.textualapp.com"]
dlackty_ has quit [Ping timeout: 264 seconds]
UziMonkey__ has quit [Ping timeout: 256 seconds]
Spaceghost|cloud has quit [Ping timeout: 272 seconds]
franckverrot has quit [Ping timeout: 264 seconds]
r0bglees0n has quit [Ping timeout: 252 seconds]
jacknagel has quit [Ping timeout: 252 seconds]
vlad_starkov has quit [Ping timeout: 252 seconds]
vivekrai has quit [Ping timeout: 256 seconds]
norplr has quit [Ping timeout: 255 seconds]
krohrbaugh has joined #ruby-lang
mistym has quit [Ping timeout: 256 seconds]
idkazuma has joined #ruby-lang
krohrbaugh has quit [Ping timeout: 252 seconds]
mucker has quit [Quit: leaving]
<ddfreyne>
judofyr: maybe I should start writing Flemish Dutch with æ ø å as well. We have the same sounds (not in Dutch Dutch though)
<julianhurley>
As you may expect, http://pastie.org/7801496 results in '100', printed to the screen. What I want to clarify is, how is the '10' passed to the area method? The only time 'area' is called is during the puts. Does the instance of Square (<Square:0x0000010084b920> ) contain all of the methods of the class square?
symm- has quit [Read error: Connection reset by peer]
symm- has joined #ruby-lang
Morphix1995 has quit [Quit: Page closed]
<judofyr>
julianhurley: the instance of Square has a reference to the class: a.class => Square
symm- has quit [Read error: Connection reset by peer]
chessguy has joined #ruby-lang
<judofyr>
julianhurley: method lookups finds methods in the class (and its superclasses) of the object
ar57 has joined #ruby-lang
<judofyr>
julianhurley: so the `a`-instance doesn't have any methods itself. it just got the data (@side_length) and it knows its class
symm- has joined #ruby-lang
bzalasky has joined #ruby-lang
JohnRKD has joined #ruby-lang
KM has quit [Read error: Connection reset by peer]
KM has joined #ruby-lang
<julianhurley>
I think I see. But the number '10' is passed to area when I write '
<julianhurley>
Also, how do I do the giant orange text? :3
ikrima has joined #ruby-lang
KM|2 has joined #ruby-lang
KM has quit [Read error: Connection reset by peer]
scottschecter has quit [Ping timeout: 245 seconds]
tarruda has joined #ruby-lang
kith has quit [Ping timeout: 256 seconds]
scottschecter has joined #ruby-lang
barttenbrinke has quit [Remote host closed the connection]
mbj has quit [Ping timeout: 256 seconds]
jsullivandigs has joined #ruby-lang
alessio_rocco has quit [Remote host closed the connection]
ar57 has left #ruby-lang [#ruby-lang]
saarinen has joined #ruby-lang
jsulliva_ has quit [Ping timeout: 260 seconds]
infecto has quit [Read error: Operation timed out]
kurko_ has joined #ruby-lang
infecto has joined #ruby-lang
wallerdev has quit [Quit: wallerdev]
runeb has quit [Remote host closed the connection]
wallerdev has joined #ruby-lang
Squarepy has quit [Remote host closed the connection]
JohnRKD has left #ruby-lang [#ruby-lang]
robbyoconnor has joined #ruby-lang
bzalasky has quit [Remote host closed the connection]
saarinen has quit [Quit: saarinen]
Mon_Ouie has quit [Ping timeout: 264 seconds]
<ikrima>
hey guys, I'm relatively new to Ruby and trying to build my own gem but I'm stuck at this error when running rake: "Command failed with status (1): [/Users/ikrima/.rvm/rubies/ruby-2.0.0-p0/bi...]
<judofyr>
ikrima: can you paste the whole output (with pastie.org)
hramrach_ has quit [Remote host closed the connection]
hramrach_ has joined #ruby-lang
nXqd has joined #ruby-lang
benlovell has joined #ruby-lang
<julianhurley>
judofyr: The 'methods' method returns an array of methods available to an object. Why is the method 'area' not present when this code is run? http://pastie.org/7801732 ?
<julianhurley>
Oh
<julianhurley>
it is
<julianhurley>
ignore me
<julianhurley>
:P
<judofyr>
julianhurley: :)
justinra_ has joined #ruby-lang
justinram has quit [Ping timeout: 258 seconds]
kke has quit [Ping timeout: 246 seconds]
Squarepy has joined #ruby-lang
<julianhurley>
judofyr: http://pastie.org/7801496 The number '10' is passed to the method 'area' when I write 'a = Square.new(10)'. Is the method 'initialize' a special method? A keyword? Is initialize the method you call when you type 'a = Square.new(10)'? Therefore, is it sort of a convention to define all your instance variable in 'initialize' in order to make those variables accessible to the methods in the class?
<julianhurley>
could you confirms this plz??
<judofyr>
julianhurley: initialize is a regular method. same is .new
<whitequark>
julianhurley: class Class; def new(*args, &block); instance = allocate; instance.send :initialize, *args, █ instance; end; end
<whitequark>
basically what #new is
<judofyr>
julianhurley: .new is basically: def new(*args); obj = allocate; obj.initialize(*args); obj end
<judofyr>
julianhurley: so yes, you should initialize stuff in initialize
<julianhurley>
:)
<julianhurley>
great! Hence the name
<judofyr>
julianhurley: exactly. and you don't have to worry about the return value of #initialize
<julianhurley>
And 'regular methods' are methods inbuilt into ruby?
<julianhurley>
'puts' would be another one, possibly?
<judofyr>
julianhurley: puts is defined in Kernel (a module) that's available everywhere
<julianhurley>
okay, then .length
<julianhurley>
.length is regular method?
<judofyr>
julianhurley: depends on the class. String has its own #length, Array has its own #length
<judofyr>
julianhurley: yes
mikestok has quit [Quit: Computer has gone to sleep.]
<julianhurley>
I see
<julianhurley>
thanks a lot guys!
<judofyr>
julianhurley: you can even override it: class String; def length; 5; end; end; "a".length #=> 5
thone_ has joined #ruby-lang
<julianhurley>
madness!
<judofyr>
julianhurley: but don't do that :P
<julianhurley>
I can't really think of a use for that :L
<julianhurley>
good to know though
symm- has quit [Read error: Connection reset by peer]
<judofyr>
julianhurley: overriding core methods isn't that useful. introducing new methods on new classes can be useful. I've writing a little script that extracts TODOs. now I can say `5.days.and_earlier` to filter for all todos that are due in 5 days
symm- has joined #ruby-lang
<judofyr>
julianhurley: class Integer; def days; …; end; end
mineiro has quit [Read error: Connection reset by peer]
thone has quit [Ping timeout: 252 seconds]
<judofyr>
julianhurley: but yeah, don't introduce too many methods on new core classes. the are global. so if you write a library that defines Integer#days it won't work with another library that defines Integer#days
mineiro has joined #ruby-lang
<julianhurley>
I'm with you
<julianhurley>
thanks!
<judofyr>
anytime!
<julianhurley>
:D
<judofyr>
julianhurley: what do you think of Ruby so far?
<julianhurley>
She's a pretty laid back kind of gal.
<julianhurley>
In all seriousness, very intuitive
<julianhurley>
I love the object orientated approach
<judofyr>
wait 'till you discover blocks
mistym has joined #ruby-lang
mistym has joined #ruby-lang
MaddinXx has quit [Remote host closed the connection]
setmeaway2 has quit [Ping timeout: 245 seconds]
<julianhurley>
Yes I have briefly dabbled with blocks
<julianhurley>
They're very useful with web applications
<julianhurley>
or...anything else now that I think about it :P
rushed has joined #ruby-lang
<julianhurley>
judofyr: So how long have you been a ruby developer?
MaddinXx has joined #ruby-lang
<judofyr>
julianhurley: hm. started playing with Ruby maybe 5-6 years ago? dunno really
<judofyr>
julianhurley: I spent a long time learning it
<rue>
Newb
<julianhurley>
judofyr: Have you for a full time job with it?
<judofyr>
Joined GitHub Feb 20, 2008, so a few years before that maybe
tylersmith has quit [Remote host closed the connection]
<judofyr>
again I want to point out that I was a real newb in my first years of Ruby
<apeiros>
badeball: because that's not how it works
<apeiros>
restrictions for auto-defining of lvars via regexen are quite rigid
<apeiros>
a) must be a literal regex, b) must be lhs, c) must use =~, d) must not contain interpolations
<badeball>
I suspected that was the case
<apeiros>
I hope I got all requirements, might be I missed some. I'm not very fond of the feature.
sepp2k has quit [Ping timeout: 258 seconds]
marr has quit [Ping timeout: 256 seconds]
Squarepy has quit [Quit: Leaving]
brianpWins has quit [Quit: brianpWins]
chessguy has quit [Remote host closed the connection]
marr has joined #ruby-lang
tenderlove has joined #ruby-lang
<julianhurley>
http://pastie.org/7802017 Now in this example, is this what is happening (starting from line 27): (1) variable 'p' is set to Person.new("Fred Bloggs") (2) The interpreter goes through class 'Person'. (3) It hits the method intialize, and calls the 'set_name' method from inside the 'initialize' method. (4) In set_name, "Fred Blogs" is passed into 'name', and "Fred Blogs" is split at the space(s) by the split method utilising regex p
<julianhurley>
attern matching. (6) The method 'set_first_name' is called from inside 'set_name', and the instance variable @first_name is set to "Fred" (7) The method 'set_last_name' is called from inside 'set_name', and the instance variable @last_name is set to "Blogs". (8) Now it goes back up to the 'name' method. It sets the instance variable of @first_name + ' ' + @last_name to "Fred" and "Bloggs" respectively, and puts a space between them
<julianhurley>
. (8) Now, "puts p.name" prints "Fred Bloggs" to the screen, because "Fred Bloggs" is the result of method "name"
<julianhurley>
Sorry if that's a bit wall o' text!
cofin has quit [Quit: cofin]
jvrmaia has quit [Remote host closed the connection]
<erikh>
so hot out
<erikh>
good god
<julianhurley>
Oh, it's not that bad!
<erikh>
perlbot | erikh: Weather for 94026: Menlo Park, CA 86??! IT'S FUCKING HOT Better than winter.
<erikh>
it's fucking hot.
<erikh>
I concur with the weather service that talks like a sailor.
kgrz has quit [Quit: Computer has gone to sleep.]
judofyr has quit [Remote host closed the connection]
<dingus_khan>
hello glorious rubyists, can someone please tell me why I'm getting a NoMethod error on the sample method in the last instance method of this class?: http://pastebin.com/1mavKZMz
mbj_ has quit [Ping timeout: 248 seconds]
<dingus_khan>
haven't been able to figure it out yet... :(
postmodern has joined #ruby-lang
marr has joined #ruby-lang
nofxx__ has joined #ruby-lang
DomKM1 has joined #ruby-lang
DomKM has quit [Ping timeout: 264 seconds]
tallship has joined #ruby-lang
<julianhurley>
Ah I think I've got this
<julianhurley>
@dingus_khan
<dingus_khan>
yes sir
<erikh>
sample isn't a method on Die
<dingus_khan>
I must be missing something basic here--I thought I could call any array method in a class definition...?
<erikh>
nope
<dingus_khan>
damn
<erikh>
and that's not a class definition, that's a method definition.
<dingus_khan>
well, now I'm lost. trying to get a random character from that die.roll method
<dingus_khan>
ah right, I meant when defining instance methods of a class
<erikh>
what is the array in your class?
<erikh>
you have one defined, do you know what it is?
justinra_ has quit [Remote host closed the connection]
<erikh>
well, in your instance that is.
<dingus_khan>
a random array passed in as an argument
<erikh>
right, and what do you do with it?
<dingus_khan>
I'm sorry, I don't follow--you mean in the instance method roll?
<erikh>
what do you do in the initializer
<erikh>
is this homework help? perhaps you'd like a book to read?
<dingus_khan>
oh, I give the length of the array as the number of sides in the die
<dingus_khan>
yes, sort of homework, and I'd love a book recommendation! eloquent ruby was over my head :/
<erikh>
and you'll learn why after about 30 of these
<julianhurley>
True
<dingus_khan>
crap, so don't click on the link then...
<erikh>
heh
<dingus_khan>
soooo tempting
<dingus_khan>
am I far off?
<julianhurley>
Well
<julianhurley>
no
<julianhurley>
nearly there
pskosinski has quit [Ping timeout: 268 seconds]
<julianhurley>
one character off
<erikh>
dingus_khan: that link above has a few books
<dingus_khan>
I feel like there's something stupid I'm missing somewhere
<dingus_khan>
one character?!
<julianhurley>
Yes :L
<dingus_khan>
zomfg
<erikh>
no
<erikh>
not one character.
<erikh>
anyhow -- read the books, please.
<dingus_khan>
erikh, I will definitely check those out
<erikh>
taking fixes is only punishing yourself.
<erikh>
fwiw, @sides is an array, not an integer.
<erikh>
and self is always going to be an instance of the class.
<dingus_khan>
true, but finding relevant information has also been a punishing experience... :/
<erikh>
so, all Objects have a method called 'class'
<erikh>
so you could type something like
<erikh>
puts @sides.class in the initializer
<erikh>
it would tell you it's an array
<andrewvos>
stay classy
<dingus_khan>
lol
<erikh>
andrewvos: heh
<erikh>
andrewvos: <3
<andrewvos>
stay_classy_san_diego?
<dingus_khan>
oh, so puts @sides.class will just display what it is, debug style?
<andrewvos>
erikh: gai
<andrewvos>
hai*
<erikh>
dingus_khan: rihgt, you still need to print it though
<andrewvos>
Good to see you're back
<erikh>
it will return the literal class it belongs to
<erikh>
andrewvos: thanks!
<dingus_khan>
and why is @sides and array if what I'm passing it is sides.length? I thought length returned an integer value..?
<erikh>
trying to re-introduce myself back in to the various freenode communities. slowly.
<erikh>
dingus_khan: you're not passing it sides.length
<erikh>
read your code again
<erikh>
you take in sides in the initializer
<erikh>
then you assign it to @sides
benanne has quit [Quit: kbai]
<erikh>
@sides.sample is what you want.
<erikh>
not self.
<erikh>
#sample being a method on arrays you can use to get a single item of it.
<julianhurley>
That's the character I was referring to
<julianhurley>
the @
<erikh>
taht would be @self.sample
<erikh>
don't try to be so clever.
<dingus_khan>
man, that is confusingly contradictory to what I understood before: @sides was supposed to be an instance variable with an integer value...
<erikh>
dingus_khan: it's not, that's @numSides
<erikh>
which you assign in your other method.
<erikh>
see?
<erikh>
length and count are the same method, fwiw.
<erikh>
just synonyms.
<andrewvos>
erikh: That implies that your absence was planned.
<dingus_khan>
right, I was wondering why I was doing what seemed like the same thing twice--that was me just following directions... :/
<erikh>
dingus_khan: this is why you don't let people solve your problems for you :)
<erikh>
anyhow!
<erikh>
dingus_khan: read the books. seriously. it will make you a lot better at this than asking questions in here will, at least at this point in your learning.
<erikh>
it's not a "go away" thing as much as it is a "this is the best way to learn" thing.
<dingus_khan>
well I'm trying to learn, and it's either learn from people or learn from material, that people wrote, which is either more or less efficient, depending on what I need to know...
<erikh>
idling in here and following the chat can teach you quite a bit
<erikh>
right sure
<erikh>
just trying to help.
<erikh>
may ruby be with you and all that.
<dingus_khan>
totally, thank you for the references, I'm definitely going to use it!
<dingus_khan>
but I can't ask a book questions the same way I can a person--my mind works funny... :(