adambeynon changed the topic of #opal to: http://opalrb.org - Ruby runtime and library on top of Javascript | 1.0.0 is near | This channel is logged at http://irclog.whitequark.org/opal
ryanstout has joined #opal
meh` has joined #opal
<meh`> fkchang, ping
ryanstout has quit [Quit: ryanstout]
ryanstout has joined #opal
ryanstout has quit [Quit: ryanstout]
[spoiler] has quit [Quit: Leaving]
meh` has quit [Ping timeout: 246 seconds]
ryanstout has joined #opal
fkchang has quit [Ping timeout: 246 seconds]
eventualbuddha has joined #opal
<shawn42> anyone around?
<e_dub> wrong time of day, shawn42 , channel generally not active for about eight hours
<shawn42> e_dub: so I'm noticing ;)
<ryanstout> yea, seems like a lot of the dev's are in europe
ryanstout has quit [Quit: ryanstout]
e_dub has quit [Quit: It's a hard knock life]
harrow has quit [Ping timeout: 256 seconds]
harrow has joined #opal
elia has joined #opal
adambeynon has joined #opal
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #opal
kludge` has quit [Ping timeout: 245 seconds]
kludge` has joined #opal
<shawn42> adambeynon: you there?
DouweM has quit [Ping timeout: 240 seconds]
<adambeynon> hi shawn42
<shawn42> I'm new to opal and I feel like I'm doing something wrong here: https://gist.github.com/shawn42/63e6e4a64f4d6da9bbcf#file-opal_pixi-rb-L3-L16
<shawn42> my Stage class needs to have a method callable from "Ruby" but also needs to act like the wrapped object because it gets passed around internally in PIXI
<shawn42> the prototype swapping feels wrong, but is that the way to go?
<adambeynon> shawn42: I used that as a quick hack inside opal-jquery, just to get it working
<adambeynon> we do need a way to support this though
<adambeynon> so, you want the "ruby object" to be just the real js object?
<adambeynon> like the way arrays in ruby are normal js arrays?
<shawn42> yes, but it would be nice to be able to Ruby-ify the external interface... so that if any of my Ruby game code interacts with that object, I can use methods like add_child instead of addChild
<shawn42> so if I could just have my cake and eat it too.. that'd be great =P
<adambeynon> shawn42: sure. would you want to have all the Kernel/Object methods on there as well?
<adambeynon> lol, yeh
<shawn42> yeah, I think so. Given the $ prefix there shouldn't be any naming conflicts so that would work
<adambeynon> shawn42: ok, well, at the moment, this requires the hacks you have setup, which is what we use in opal-jquery
<adambeynon> but
<adambeynon> Im thiking about a better way to do it
<adambeynon> something like
<adambeynon> class Stage < `window.PIXI.stage`; .... ; end
<adambeynon> which will do all the work on setting up your native js prototype to work as a ruby object would
<adambeynon> that doesnt currently work, but we used to have it, and it did work nicely
<shawn42> yeah, that makes sense
<adambeynon> the only thing to note is, that we wouldn't be able to support method_missing on that object
<shawn42> I wonder if it makes more sense to treat it like a module that is being mixed in, rather than a base class
<shawn42> class Stage; include `window.PIXI.stage`; ... ; end
<adambeynon> we could do. the only thing to be careful of is that if you include any modules or define any methods before that, then we might loose them
<adambeynon> basically, with this approach we rip out the current prototype and replace it with your native javascript prototype
<adambeynon> thus loosing any methods already defined
<shawn42> could we just loop over window.PIXI.stage's prototype and copy them into our prototype (leaving our previous functions in place)?
<shawn42> <-- is not JS expert and doesn't remember exactly how JS prototypes work
<adambeynon> shawn42: we can do it that way. but, if someone creates a new instance of `window.PIXI.stage` somewhere else, then it wont have any of our ruby methods
<adambeynon> as we are basically creating a subclass of it (in this case)
<shawn42> yeah, I didn't think of that
<adambeynon> shawn42: recently I tried re-writing opal-jquery to use a wrapper class instead, and its too awkward
<adambeynon> I had to keep converting back and forth between wrappers
<adambeynon> it makes more sense to be to extend prototypes like this, when possible
<adambeynon> the only big downside is loosing method_missing
<shawn42> I wonder if you could just formally endorse your "hack"
<shawn42> so I don't have to execute raw js / prototype trickery
<adambeynon> shawn42: I will introduce something as we need it for jQuery
<adambeynon> we have two options, as I see it
<adambeynon> either:
<adambeynon> (using jquery as an example)
<adambeynon> class Element < `$`; ... ; end
<adambeynon> or
<shawn42> and just hide it behind some thing that says "if you extend a native class, you cannot extend Object"
<adambeynon> Element = Class.new(`$`) do ... end
<adambeynon> yep
<shawn42> adambeynon: aren't those the same option ;)
<adambeynon> shawn42: kind of :D they go through slightly different code, but yeah
<adambeynon> we could support both, yes
<shawn42> cool, +1
<adambeynon> or, to be contraversial, if we introduced method_tables, then this would all be a lot easier
<adambeynon> but, much uglier generated code
<adambeynon> controversial*
<shawn42> heh
<shawn42> adambeynon: oh, one more thing
GitHub63 has joined #opal
GitHub63 has left #opal [#opal]
<GitHub63> opal/master b68dc4e Adam Beynon: Fix lots of heredoc parsing bugs (needs cleanup)
<GitHub63> [opal] adambeynon pushed 1 new commit to master: http://git.io/0m7Ecg
<shawn42> in my example, I'm trying to get that function out of raw js and into Opal, but I haven't done anything with blocks yet in Opal
travis-ci has joined #opal
<travis-ci> [travis-ci] Build details : http://travis-ci.org/opal/opal/builds/13309648
<travis-ci> [travis-ci] opal/opal#1348 (master - b68dc4e : Adam Beynon): The build was fixed.
travis-ci has left #opal [#opal]
<adambeynon> shawn42: I commented on the gist
<adambeynon> that should do it
<adambeynon> if you have some wrapper around `requestAnimFrame` then we can replace that with a ruby call as well
e_dub has joined #opal
<shawn42> k, trying
<adambeynon> elia: with that heredoc commit, we went from 12 rspec parsing errors down to 4
<adambeynon> booom
<elia> adambeynon, super!
<shawn42> \o/
<adambeynon> .. to 3
GitHub39 has joined #opal
GitHub39 has left #opal [#opal]
<GitHub39> [opal] adambeynon pushed 1 new commit to master: http://git.io/VP5Q3g
<GitHub39> opal/master 4986f11 Adam Beynon: Stop generating empty fragments when require() used as expression
elia has quit [Quit: Computer has gone to sleep.]
harrow has quit [Remote host closed the connection]
<adambeynon> shawn42: did that block code work?
<shawn42> yeah
travis-ci has joined #opal
<travis-ci> [travis-ci] opal/opal#1349 (master - 4986f11 : Adam Beynon): The build passed.
travis-ci has left #opal [#opal]
<travis-ci> [travis-ci] Build details : http://travis-ci.org/opal/opal/builds/13310563
<shawn42> adambeynon: thanks, here's what I came up with: https://gist.github.com/shawn42/63e6e4a64f4d6da9bbcf
<e_dub> oh cool shawn, working on a nice wrapper for webgl stuff?
harrow has joined #opal
<shawn42> e_dub: starting to
<e_dub> word
elia has joined #opal
meh` has joined #opal
<elia> meh`, think you'll love this: http://youtu.be/TS1lpKBMkgg?t=16m33s
[spoiler] has joined #opal
GitHub9 has joined #opal
<GitHub9> opal/method_table e2b91a2 Adam Beynon: Skip branch on travis
GitHub9 has left #opal [#opal]
<GitHub9> [opal] adambeynon created method_table (+1 new commit): http://git.io/BBCwPg
<meh`> adambeynon, what's the plan for method tables?
<adambeynon> meh`: once last try at them to see if they are better than prototype hacking
<adambeynon> I was reading through an old Opal app, where I used a custom dom library
<adambeynon> back from the method_table days
<adambeynon> it was awesome doing
<adambeynon> my_native_el.$m = Opal.Element.$m_tbl;
<adambeynon> but, just playing atm :)
<meh`> adambeynon, it might still be an extremely good idea to keep Native as is
<meh`> adambeynon, especially in <IE9 adding things to objects might crash
<meh`> if they're DOM and other kinds of "special" objects
<adambeynon> meh`: how dangerous is it? Didn't prototype.js add all their methods to elements?
<meh`> adambeynon, not in IE
<meh`> you still had to wrap them
<meh`> also I think passing anything but the real arguments to a function is going to make things very ugly
<meh`> fucking up with arguments ends up breaking a lot of things
<meh`> so I'd rather we stayed as we are
<meh`> same goes with blocks
<meh`> but I wouldn't oppose a debug-only $iter that does its thing internally
<meh`> but yeah, don't underestimate the utility of arguments
<meh`> we use it everywhere in the corelib
<adambeynon> mainly for blocks. I would prefer to keep blocks as a normal argument setup (as in, dont pass self)
<meh`> adambeynon, how do you mean?
<adambeynon> well, only methods would accept `self` as their first value
<adambeynon> blocks would still be `my_block(1, 2, 3)`
<meh`> I don't know, I'm not convinced, we'll see how it goes
<adambeynon> meh`: yeah, Im just playing with it. my main concern is that it will start generating really ugly code again, which is a massive blocker in itself
<adambeynon> but, we now have a shed-load of tests, so we can really test performance of a larger code base
<e_dub> elia nice!
<adambeynon> elia: awesome
<elia> :)
DouweM has joined #opal
fkchang has joined #opal
<meh`> fkchang, hey
<fkchang> hey
<meh`> fkchang, the shekels app should be finished
<fkchang> cool, I'll pull and check it out
<fkchang> meh`: you have your home directory in the Gemfile
<meh`> hue
<meh`> fkchang, sorry, fixing that
<meh`> fkchang, fixed
eventualbuddha has quit [Ping timeout: 272 seconds]
<meh`> fkchang, worthy of note is the app/component/payment_list.rb
<fkchang> meh`: Uncaught NoMethodError: undefined method `split' for nil
<fkchang> Uncaught NoMethodError: undefined method `sort_by' for nil
<meh`> fkchang, what browser?
<meh`> fkchang, and what version of everything?
<fkchang> safari and chrome
<meh`> sort_by had a bug or something
<meh`> I remember fixing it recently
<meh`> like, yesterday morning
<meh`> mh
<meh`> what version of chrome?
<fkchang> Version 30.0.1599.101
<fkchang>
<meh`> the same I have
<meh`> now ait
<meh`> wait
<meh`> happening here too
<meh`> I must have been on an older version
<meh`> and something broke
<meh`> lol
<meh`> fkchang, I forgot to push the latest changes to lissio :D
<meh`> this is what happens when you code on a train without internet
<meh`> fkchang, update the bundle
<fkchang> meh`: seems to be working, would this line be from when it was crashing before, but some data was persisted
<fkchang> 2013-10-21..2013-10-27
<fkchang> You spent ₪ 13.37 for #<Person:692> on Friday
<meh`> fkchang, yeah, it was left over data from when you tried few days ago
<meh`> do a localStorage.clear()
<elia> meh`, cool stuff, can't wait to read the code
<elia> meh`, already put on heroku?
<meh`> elia, no need really, I could add the generated stuff to the gh-pages for the repo
<meh`> I think I will do just that
<meh`> if only I knew how to rake dist with opal-sprockets
<elia> meh`, better
<elia> meh`, dunno exacly how but sprockets it's capable of doing concat+minify for you
<meh`> elia, do you have time to find out? I know nothing about sprockets
<meh`> I'll add it to lissio
<meh`> but I think I'll go the easy way
<elia> meh`, right now I'm in a code/deploy loop debugging stuff+memcached
<meh`> elia, no worries
<meh`> it can wait
<adambeynon> thats how we build the corelib using sprockets
<adambeynon> should be the same idea
<adambeynon> notably: ` Opal::Environment.new['application'].to_s`
<adambeynon> where "application" is your main entry point
<adambeynon> not sure how to gzip/minifiy with sprockets though - I always use the two method in our Rakefile
<elia> adambeynon, meh`, I think it's environment.css_compressor = compressor.to_sym
<meh`> mmh
<meh`> something's not working
<adambeynon> meh`: what error?
<meh`> adambeynon, no no, unrelated
<meh`> shekels is not working when put on gh-pages
<meh`> for some reason
<meh`> mh
<adambeynon> and the same code works fine locally? (when built through Opal::Environment ? )
<meh`> adambeynon, I used the spartan way
GitHub136 has joined #opal
GitHub136 has left #opal [#opal]
<GitHub136> [opal] elia deleted v0.0.1.a at f5a99e6: http://git.io/GNlUFw
<meh`> adambeynon, I rackup'd and downloaded the generated stuff
GitHub10 has joined #opal
<GitHub10> [opal] elia deleted v0.0.2 at 1ab26cf: http://git.io/oSb59A
GitHub100 has joined #opal
GitHub100 has left #opal [#opal]
<GitHub100> [opal] elia deleted v0.0.3 at 87c0931: http://git.io/iS1JXA
GitHub10 has left #opal [#opal]
GitHub53 has joined #opal
GitHub53 has left #opal [#opal]
<GitHub53> [opal] elia deleted v0.0.4 at d7ec2e3: http://git.io/E60d7w
GitHub143 has joined #opal
GitHub143 has left #opal [#opal]
<GitHub143> [opal] elia deleted v0.0.5 at a076aee: http://git.io/wLgBkw
GitHub175 has joined #opal
GitHub175 has left #opal [#opal]
<GitHub175> [opal] elia deleted v0.1.0 at 6508607: http://git.io/44x9CQ
GitHub133 has joined #opal
GitHub133 has left #opal [#opal]
<GitHub133> [opal] elia deleted v0.0.6 at 15f97d0: http://git.io/7uU95A
GitHub117 has joined #opal
GitHub117 has left #opal [#opal]
<GitHub117> [opal] elia deleted v0.2.0 at 91d1138: http://git.io/8zlhng
GitHub61 has joined #opal
GitHub61 has left #opal [#opal]
<GitHub61> [opal] elia deleted v0.2.1 at b170c98: http://git.io/Xh39QA
GitHub137 has joined #opal
GitHub137 has left #opal [#opal]
<GitHub137> [opal] elia deleted v0.3.1 at 7749e79: http://git.io/SvcbsA
GitHub62 has joined #opal
<GitHub62> [opal] elia deleted v0.3.2 at 096af93: http://git.io/vQn_KQ
GitHub62 has left #opal [#opal]
GitHub71 has joined #opal
<GitHub71> [opal] elia deleted v0.3.3 at 8fde30f: http://git.io/gkTfyg
GitHub71 has left #opal [#opal]
GitHub167 has joined #opal
GitHub167 has left #opal [#opal]
<GitHub167> [opal] elia deleted v0.3.4 at 0dbef73: http://git.io/nDtvig
GitHub129 has joined #opal
GitHub129 has left #opal [#opal]
<GitHub129> [opal] elia deleted v0.3.6 at 6619852: http://git.io/-xibXQ
GitHub154 has joined #opal
<GitHub154> [opal] elia deleted v0.3.5 at c376693: http://git.io/Pbhraw
GitHub154 has left #opal [#opal]
GitHub34 has joined #opal
GitHub34 has left #opal [#opal]
<GitHub34> [opal] elia deleted v0.3.8 at cf79575: http://git.io/3tVH5g
GitHub22 has joined #opal
<GitHub22> [opal] elia deleted v0.3.7 at dda1edb: http://git.io/llXskw
GitHub22 has left #opal [#opal]
<elia> adambeynon, removed a bunch of tags sneaked in from opal-rails… :(
<elia> leaving, cya
<adambeynon> ahh, I noticed them earlier. ok :D
<adambeynon> cya
<meh`> mh
<meh`> it doesn't work on a static webserver
eventual1uddha has joined #opal
elia has quit [Ping timeout: 240 seconds]
<meh`> and it doesn't throw any error
<meh`> mh
<meh`> ooh
<meh`> lol
<meh`> I see
<meh`> since the root is different the router fucks up
<meh`> adambeynon, fkchang, http://meh.schizofreni.co/shekels does it work to you?
<meh`> 86K gzipped
<meh`> not bad
<fkchang> meh`: not on safari, but did on chrome
<meh`> fkchang, yeah, I don't have Safari to test it
<meh`> it's probably a bug in opal-browser in that case
<meh`> fkchang, what safari version?
<fkchang> Version 6.0.5 (8536.30.1)
<meh`> snab
<meh`> only 5.1.7 for windows
<fkchang> is there a test suite I could run in the browser?
<meh`> fkchang, opal-browser has one, but the tests are kind of limited so far
<meh`> I don't have the time to document what's left and add more tests for now
<meh`> but well
<meh`> I guess if it's broken in 6 it must be broken in 5 too
eventual1uddha has quit [Ping timeout: 265 seconds]
<adambeynon> meh` r.e. safari
<adambeynon> localStorage looks right
<adambeynon> only thing looking wrong is the display
<adambeynon> "billy owes you ₪ 2.1 on undefined"
<meh`> lol
<meh`> something wrong with strftime then
<meh`> or Date.parse
<meh`> I'm pretty sure it's that
<meh`> we should implement our own date parsing thing
<meh`> and by we I mean me
<meh`> well, on safari 5 nothing works
<meh`> lol
<adambeynon> yeah.. and all the text above was like "undefined undefined undefined - undefined undefined"
<adambeynon> so yeh, dates it seems
<meh`> well, it seems on safari 5 it doesn't work at all
<meh`> something to do with events
<meh`> but I have no time to debug that
<meh`> adambeynon, can you do a simple test for me on safari please?
<adambeynon> meh`: sure
<meh`> adambeynon, Date.parse("2013-10-31T18:57:33+0100")
<meh`> at least we know if it's the parsing or the formatting
<meh`> on 5 it returns NaN
<adambeynon> yeah, the parsing seems to be the issue
<adambeynon> specifically "+0100"
<meh`> I see
<meh`> that's the ISO standard for dates tho
<meh`> fucking browsers
<meh`> I'll open an issue, maybe some new contributors from RubyConf will want to tackle it
<adambeynon> other libs must have the same problem (if that is what the problem is)
<meh`> yeah
<meh`> but I had already enough "fun" implementing #strftime
<adambeynon> meh`: looking at one of my apps, I had to do something similar
eventual1uddha has joined #opal
<adambeynon> just never got around to backporting it to opal
<meh`> adambeynon, well, if you can fix it before rubyconf :)
eventual1uddha has quit [*.net *.split]
elia has joined #opal
GitHub11 has joined #opal
<GitHub11> opal/method_table 88ec514 Adam Beynon: Initial commit of reworking runtime for method tables
GitHub11 has left #opal [#opal]
<GitHub11> [opal] adambeynon pushed 1 new commit to method_table: http://git.io/ayVqLg
<meh`> elia, http://meh.schizofreni.co/shekels/ if you want to try it
<adambeynon> is that beign defined on the element itself?
<adambeynon> being*
<meh`> adambeynon, the $data? yes
<meh`> it has to
<meh`> there are other things being defined too
<meh`> but now that I think of it calling them with the same method prefix was retarded of me
<meh`> I'll change them when we have an official runtime special var prefix
<adambeynon> meh`: was just wondering in terms of affecting native elements
<adambeynon> ie7/8 etc
<meh`> adambeynon, from the research I made those *should* work
<meh`> even on IE6
<meh`> but I can always fix it in the compatibility stuff
<adambeynon> yeah, I think so
<meh`> the issues mostly come when you touch the prototype
<adambeynon> meh`: yeah, but *instances* seem to be ok
<adambeynon> that was my thoughts with method_tables
<adambeynon> .. if they work out
<meh`> yeah
<meh`> but I really don't like recv.$method(recv, ..)
<meh`> :(
<adambeynon> meh`: depends on what works out to be fastest
<adambeynon> .call() seems to add extra overhead
<adambeynon> or I assume it would
<meh`> .call would be even worse
<meh`> I don't like how it reads
<meh`> I don't even want to imagine how "a".b.c.d would look
<adambeynon> but, how about `StringSubclass.new("foo").b.c.d` ;)
<meh`> but we can already achieve it with the prototype swizzling
<adambeynon> yeh, but we have to forward everything through method_missing
<adambeynon> dinner : back in 20
<meh`> yes, but those are few cases
<meh`> slowing down all cases and making the code uglier for some rare cases doesn't sound like a good idea
<meh`> with the prototype swizzling you're only affected if you're using inherited classes
<meh`> with the method tables everything is affected
<meh`> from speed to readability
elia has quit [Quit: Computer has gone to sleep.]
<adambeynon> but we cant prototype swizzle things like jquery for method_missing
<meh`> why aren't you just wrapping it?
<meh`> this is seamless integration all over again
<adambeynon> jquery is very awkward to wrap
<meh`> adambeynon, so is the DOM API
<adambeynon> exactly
<meh`> but they're limited cases
<meh`> that's the point of a library
<meh`> working around the awkwardness for everyone else to use
<meh`> think about it well through
<adambeynon> but thats fine for the dom, but everytime you want to work with another library, we keep having to have `element.to_n` calls all over the place
<meh`> and that's the proper way to go, or we're going the seamless integration direction away
<meh`> we're dealing an uglier generated code for some half-assed seamless integration
<meh`> and slower too
<meh`> so yeah, think it well through before merging it in, if you're going in that direction
<meh`> I don't want to see another switcharoo game on master
<adambeynon> yep. this will all be in a pull request back to master, with all the pros, cons + example code so it can be decided on then
<meh`> adambeynon, you should also try using it in your applications
technoguyrob5 has joined #opal
<technoguyrob5> I have a quick question
<technoguyrob5> I'm trying to convert a ruby file I wrote to javascript
<technoguyrob5> But am getting some parse errors
<technoguyrob5> That's the file
<technoguyrob5> The error is:
<technoguyrob5> │1.9.3p392 :028 > ff = Opal.compile(File.read('src/finite_fields.rb')); print 1 │RuntimeError: parse error on value "end" (END) :(file):114 │ from /Users/robertk/.rvm/gems/ruby-1.9.3-p392/bundler/gems/opal-4986f119b306/lib/opal/parser.rb:51:in `on_error' │ from (eval):3:in `_racc_do_parse_c' │ from (eval):3:in `do_parse' │ from /Users/robertk/.rvm/gems/ruby-1.9.3-p392/bundler/gems/opal-4986f
<adambeynon> technoguyrob5: hi. are you running opal from github, or a gem release?
<technoguyrob5> github
<technoguyrob5> gem 'opal', git: 'git://github.com/opal/opal.git' 110 end │~
<technoguyrob5> Is that right?
<adambeynon> technoguyrob5: ah, the issue is the first line
<technoguyrob5> The error is occuring between lines 86 and 114 of the aforementioned file
<technoguyrob5> Oh ok
<adambeynon> we dont support =begin .. =end yet
<technoguyrob5> Weird, because
<adambeynon> we really should
<technoguyrob5> When I removed all of the code
<technoguyrob5> Except =begin and =end
<technoguyrob5> It worked :p
<technoguyrob5> Let me try removing the comment
<adambeynon> let me try
<technoguyrob5> Same issue :(
<technoguyrob5> Same line though, weird..
<technoguyrob5> I think the =begin and =end got fixed, bc it compiles that fine
<technoguyrob5> I can confirm it compiles the comment correctly
<meh`> adambeynon, you did add support to =begin and =end, I remember that
<technoguyrob5> 1.9.3p392 :031 > ff = Opal.compile(File.read('src/finite_fields.rb')); print 1 1 => nil 1.9.3p392 :032 > ff => "/* Generated by Opal 0.4.4 */\n(function($opal) {\n var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice;\ n $opal.add_stubs([]);\n return nil\n})(Opal);\n"
<technoguyrob5> Could it be operator overloading?
<technoguyrob5> def *(y) ... end
<meh`> technoguyrob5, no, that should work
<meh`> or number operations wouldn't work :P
<technoguyrob5> Hehe
<technoguyrob5> Strange...
<meh`> technoguyrob5, we don't use such tricks, https://github.com/opal/opal/blob/master/corelib/numeric.rb#L64-L73
<technoguyrob5> Ahhh
<technoguyrob5> So I have to compile the operator code by hand ot JS
<technoguyrob5> And then wrap it in %x ?
<meh`> technoguyrob5, no
<meh`> technoguyrob5, if it's a parsing error it's just a bug in the parser
<technoguyrob5> Right
<technoguyrob5> Removing all the operators in the first class
<technoguyrob5> lines 87 through 141
<adambeynon> ahhh, I found it
<technoguyrob5> results in RuntimeError: parse error on value "end" (END) :(file):51
<adambeynon> for ... in
<technoguyrob5> Nice!
<technoguyrob5> Is that the problem?
<adambeynon> yeah, we havent sorted those yet
<technoguyrob5> Just iterate manually
<technoguyrob5> Ok great
<technoguyrob5> And no ranges?
<meh`> technoguyrob5, we support ranges
<meh`> technoguyrob5, also I don't think you have to #to_a on the range to use for .. in
<adambeynon> yeah, ranges are fine
<technoguyrob5> (0..(@primes - 1).to_a.each it is
<meh`> technoguyrob5, just to (1 .. (p - 1)).each { return x if (x * n % p) == 1 }
<technoguyrob5> Thanks!
<meh`> technoguyrob5, you don't need to call #to_a on an Enumerable
<meh`> it's already Enumerable
<technoguyrob5> Right
<technoguyrob5> Good point
<meh`> you're just slowing everything down that way :)
<adambeynon> never used for-in loops, which is why they aren't done yet :P
<technoguyrob5> Especially if it's large :)
<meh`> yeah, neither did I
<adambeynon> does a for-in just compile to #each ?
<technoguyrob5> Hehe, yeah it was a bad habit
<meh`> adambeynon, basically, yes
<meh`> adambeynon, except it doesn't create a new scope
<meh`> have fun figuring that out :P
<technoguyrob5> oh man...
<adambeynon> :(
<meh`> adambeynon, if it were for me, I'd just declare it unsupported
<meh`> we can't support the same semantics
<technoguyrob5> So basically...
<technoguyrob5> Since a new scope gets created
<technoguyrob5> my .self's now won't work
<technoguyrob5> So I need to make a local
<technoguyrob5> _self = self
<meh`> technoguyrob5, no, you don't have that problem
<technoguyrob5> Want me to submit a pull request if I get the for in business sorted out?
<meh`> for .. in works differently as to variable declarations, that's all
<meh`> when you do a = 3 in a for .. in
<meh`> it's available to the following code
<meh`> in a block it's not the case
<adambeynon> meh`: I think we could work around it. when the parser hits a new variable, we can get the iter to check if its marked as a for-in loop, and push the variable up a scope
<technoguyrob5> ok you're right
<technoguyrob5> 1.9.3p392 :059 > class X 1.9.3p392 :060?> def set=(test) 1.9.3p392 :061?> print test 1.9.3p392 :062?> end 1.9.3p392 :063?> def test 1.9.3p392 :064?> (0..2).each { |x| self.set = x } 1.9.3p392 :065?> end 1.9.3p392 :066?> end => nil 1.9.3p392 :067 > X.new.test 012 => 0..2
<technoguyrob5> The instance scope gets preserved
<meh`> adambeynon, yeah, you can compile the body differently, and define temporaries in the outer scope
<meh`> shouldn't be an issue
<meh`> but I still think using for in Ruby is bad practice
<adambeynon> eek, =begin..=end doesnt increase the line numbers correctly
<adambeynon> need to fix that
<adambeynon> meh`: I just compiled that file with master + method_table branch
<adambeynon> I am now deleting thr mehod_table branch
<adambeynon> ;)
<technoguyrob5> I'm not sure if I helped with Opal here or just confused you guys.. :P
<meh`> adambeynon, hahaha
<adambeynon> technoguyrob5: there is lots of confusion happening here, so its all good ;)
<adambeynon> meh`: I have literally wasted a day
<meh`> adambeynon, should have warned you
<meh`> I just hope you don't come back to method_tables in few months when you forget about this :P
GitHub185 has joined #opal
GitHub185 has left #opal [#opal]
<GitHub185> [opal] adambeynon deleted method_table at 88ec514: http://git.io/CNG51g
<adambeynon> meh`: we have logs now - I can look back and remember the pains.
<adambeynon> right, onto something useful now
<adambeynon> Time + Date parsing, woohoo
<technoguyrob5> Oh god, be careful...
<technoguyrob5> JS dates are programmer hell
<technoguyrob5> We had a bug in production in our customer dashboard because, well...apparently Date.parse("08/31/2013") = 08-30-2013
<technoguyrob5> I can't remember if that's the right date, but it was something like that
<technoguyrob5> Err, new Date() rather than .parse
<adambeynon> technoguyrob5: yeah, Im not feeling overly optimistic about it
<adambeynon> I might read through moment.js for some inspiration
<adambeynon> although last time I looked, it was quite monolithic in size
<technoguyrob5> or just use a wrapper library
<technoguyrob5> http://www.datejs.com/
<technoguyrob5> Meaning, force the include of that js file
<technoguyrob5> For date manipulation
<technoguyrob5> Lazy = functional!
GitHub151 has joined #opal
<GitHub151> opal/master 77e8175 Adam Beynon: Lexer should increase line count correctly in =begin..=end comments
GitHub151 has left #opal [#opal]
<GitHub151> [opal] adambeynon pushed 1 new commit to master: http://git.io/qt25ZQ
eventual1uddha has joined #opal
<adambeynon> technoguyrob5: in one opal app, I have date.js included, and it does fix everything
<adambeynon> might be a good option to look at actually
<adambeynon> or atleast work out what they fix and how
travis-ci has joined #opal
<travis-ci> [travis-ci] opal/opal#1350 (master - 77e8175 : Adam Beynon): The build passed.
<travis-ci> [travis-ci] Build details : http://travis-ci.org/opal/opal/builds/13335237
travis-ci has left #opal [#opal]
<technoguyrob5> Ohm an
<technoguyrob5> Oh man
<technoguyrob5> This is tricky
<technoguyrob5> I was relying on the fact that 3/4 = 0 in Ruby
<technoguyrob5> And similar operations
<technoguyrob5> But that fails in JS
<technoguyrob5> so now I have to floor stuff
<adambeynon> ah, yeh... floats and ints
<technoguyrob5> How do I export things to global variables?
<technoguyrob5> Like window.some_variable
<adambeynon> $global.some_variable = 3.142
<adambeynon> or
<technoguyrob5> Awesome, thanks. Or Opal.
<technoguyrob5> Opal.FiniteField e.g.
<technoguyrob5> I will show you the fruits of my labor in a second
<adambeynon> top level classes will be put onto Opal automatically
<adambeynon> ::FOO = 100 <- that will put any constant on Opal
<technoguyrob5> Nice that works!
<technoguyrob5> Last one, sorry to be such a bug: You guys haven't implemented any way to do IO streams on non-files, have you? I have one method that takes an IO object, usually a File, but I would like to be able to convert the resulting output to a string in JS so it can get appended to the DOM
<technoguyrob5> e.g.
<technoguyrob5> def some_method(stream)
<technoguyrob5> stream << 'hello there'
<technoguyrob5> stream
<technoguyrob5> end
<technoguyrob5> and then in JS I flush the stream
<meh`> technoguyrob5, use StringIO
<technoguyrob5> Awesome, it works, thank you
<fkchang> adambeynon: any thoughts on method definitions/json? I realize that I pretty much have next week to put that into opal-inspector if you figure out a first pass
<adambeynon> fkchang: I have been playing with it
<fkchang> maybe a separate branch for a rubyconf version, leaving time for a real version later, seems like u have lots on ur plate
<adambeynon> source_file + source_line would be useful too
<adambeynon> fkchang:
<adambeynon> something like that
<adambeynon> and then opal-inspector can just go through it as it pleases
<fkchang> that's not bad, though an array would make for costly lookups
<fkchang> maybe a hash of fully qualified methods, as a start
<adambeynon> yeah. the only thing I dont know, is how to get the browser to load these extra "metadata" files
<adambeynon> i.e. how to automate it
<adambeynon> sourcemaps are loaded by a simple comment in the generated source
<adambeynon> but that wont really help in this case
<adambeynon> unless Opal::Server offers some special path to load the information from
<fkchang> compile option to preload everything?
<fkchang> or maybe parse option in the new scheme
<adambeynon> fkchang: do you imagine running opal-inspector using opal-sprockets (i.e. Opal::Server) ?
<adambeynon> as in, would you compile everything using a Rake task, or would you run opal-inspector on the fly using the opal server?
<fkchang> ideally I'd like to do both, my demo code is a static file, but I imagine real apps would be via some server, I'd target rails, sinatra and opal server
<meh`> and lissio server :>
<fkchang> is there a lissio server?
<fkchang> running on elixir?
<meh`> no, it's just a modified Opal::Server
<meh`> to work with lissio
<meh`> it will support prerendering of the frontend for crawling
<adambeynon> meh`: what did you need to change?
omninonsense has joined #opal
<meh`> well, the code was a bit ugly
<meh`> so I cleaned that up
<meh`> it sends the index on everything that isn't a static file
<meh`> to support HTML5 history
<adambeynon> fkchang: If you run it through Opal::Server, it can be done VERY easily
<adambeynon> static is a bit trickier
<fkchang> adambeynon: so anyways, I don't know if there's an easy scheme to handle both static and dynamic querying. I suppose you could load up the hash, and if it's not there, and u know the system is server based, query the server
<fkchang> adambeynon: I could do a version using the server
<adambeynon> fkchang: with the timeframe, I think if we could do just Opal::Server for now, we can look again at static building
<adambeynon> then it can just be an option on opal server
<adambeynon> server.metadata = true
<adambeynon> or whatever
<fkchang> adambeynon: I'm good w/that. I think u had a "getting started w/opal server doc" somewhere
[spoiler] has quit [Ping timeout: 246 seconds]
<adambeynon> fkchang: yeah, needs updating a bit, but it is there ;)
<fkchang> adambeynon: that'd be cool. I need to put a blurb about opal-server into my preso too
<fkchang> now if I can grok lissio in time, maybe I'll rewrite it w/lissio components
<adambeynon> fkchang: and some tests written with rspec? ;)
<meh`> fkchang, if you need anything just ask
<fkchang> adambeynon: rspec would be cool, how's that coming along
<adambeynon> fkchang: 1 parsing error and 2 line changes because they use mutable strings
<adambeynon> apart from that, it runs like a champ
<meh`> adambeynon, did you try sending a pull request for that?
<adambeynon> meh`: not yet. Im still searching the code base for any other places that they use mutable strings
<adambeynon> incase our code just hasnt caused it to run yet
omninonsense is now known as [spoiler]
<adambeynon> back in a tick
adambeynon has quit [Quit: ["Textual IRC Client: www.textualapp.com"]]
<technoguyrob5> @adambeynon
<technoguyrob5> Thanks guys, you all rock!! http://therobert.org/finite_fields/index.html
<meh`> technoguyrob5, nice
<technoguyrob5> =]
<fkchang> technoguyrob5: I like the powered by opal logo
<meh`> technoguyrob5, although I'd put that logo on the top right corner
<meh`> it covers part of the table for me
<technoguyrob5> Haha, thanks. I wanted to make it link back to you guys but I want to link to the source. Maybe two floating thingies?
<technoguyrob5> Ok
<technoguyrob5> fixed
adambeynon has joined #opal
<meh`> adambeynon, what do you think of my directory structure proposal?
<adambeynon> meh`: I was thinking similar
<adambeynon> well
<adambeynon> just one dir to stdpath
<adambeynon> opal
<adambeynon> opal/opal.rb
<adambeynon> opal/corelib/array.rb
<adambeynon> opal/singleton.rb
<meh`> nngh, no, I'd rather have the stdlib in its own dir
<meh`> it makes things clearer imho
<adambeynon> that gives me a parse error in ruby 2.0
<adambeynon> seems they have removed it from master
<meh`> adambeynon, yeah, I was using master to test
<meh`> they removed it indeed
<adambeynon> not sure if its a ruby-2.0 specific thing that it wont parse
<technoguyrob5> http://therobert.org/finite_fields/index.html cleaned it up a bit
<meh`> technoguyrob5, you should use #coerce instead of redefining methods on Fixnum
<technoguyrob5> meh`: Thanks, I didn't know about that!
omninonsense has joined #opal
[spoiler] has quit [Ping timeout: 246 seconds]
omninonsense is now known as [spoiler]
<technoguyrob5> meh`: What about non-commutative operations like division?
<technoguyrob5> Is there a way to figure out what operation is being accessed from inside the coerce method?
<meh`> technoguyrob5, yes and no
<technoguyrob5> 1/x gives me x atm
<meh`> technoguyrob5, the easy way is returning a coerced object with a different #/ method
<technoguyrob5> Because coerce flips the order
<technoguyrob5> Interesting...
<meh`> technoguyrob5, also keep in mind there might be bugs in the Opal coercion stuff, which also why you really really should do it
<meh`> there's not much documentation about this
<technoguyrob5> I see, I was worried that might have been a problem
<meh`> and there's no specification on how it should work
<meh`> so test it in Ruby first
<meh`> and if Opal does something weird report it, please
<meh`> technoguyrob5, there was a blog post about this issue somewhere
<technoguyrob5> Ok, I will
<meh`> it had some examples
<meh`> I'll see if I can find it
<meh`> search for NotSubtractable
<meh`> it's basically the same kind of problem you're having now
<meh`> but changing core methods is generally a very very bad idea
<technoguyrob5> I knew there was a better way, but this was a half-Sunday project, so I couldn't be bothered to research the details. This is really nice to know
<technoguyrob5> Maybe I'll start a Ruby implementation of Sage now that I know this... :p
<meh`> technoguyrob5, and when you feel courageous you could move to using lissio instead of generating HTML and having a CSS file :P
<technoguyrob5> meh`: Haha yeah, I know, I would do all this stuff, I've written compilers and managed massive Rails and Backbone projects, I was just super fast cranking out lazy ;) Funny is it probably would've taken less time that way
elia has joined #opal
adambeynon has quit [Quit: Textual IRC Client: www.textualapp.com]
DouweM has quit [Read error: Connection reset by peer]
DouweM has joined #opal
fkchang has quit [Ping timeout: 245 seconds]
meh` has quit [Ping timeout: 245 seconds]