These are chat archives for opal/opal

20th
Aug 2015
meh.
@meh
Aug 20 2015 01:27
@dancinglightning can you test parslet works without the blankslate removal on master please?
unless I'm dumb and that wasn't you
mh, nope, blocked by exist
meh.
@meh
Aug 20 2015 02:34
@dancinglightning yeah, no luck, there's another compilation issue
@dancinglightning at least I added the missing StringScanner methods :P
Martin Becker
@Thermatix
Aug 20 2015 11:14
could I have some clarification regarding inheritance please?
I have a base class:
class Base  
    include React::Component
    def initialize(native)
        @native = native
    end
end
and then an app class:
```ruby
class App < Base
define_state(:logged_in) {:false}
end
```
(whoops)
it complains Uncaught NoMethodError: undefined method `define_state' for #<App:0xd8>
shouldn't it have access to define_state?
Elia Schito
@elia
Aug 20 2015 11:17
is define_state defined in the superclass (Base)?
Martin Becker
@Thermatix
Aug 20 2015 11:17
it's included from include React::Component
Elia Schito
@elia
Aug 20 2015 11:17
could be a bug
Martin Becker
@Thermatix
Aug 20 2015 11:17
since I was doing it in every class, I thought it easier to do that in a base class and then just inherit form base
specificly I have define_state(:logged_in) {:false} inside of
before_mount do
    define_state(:logged_in) {:false}
end
which is where the error is happening
Elia Schito
@elia
Aug 20 2015 11:20
which opal version?
Martin Becker
@Thermatix
Aug 20 2015 11:20
"~> 0.8"
Elia Schito
@elia
Aug 20 2015 11:20
also, does it work outside of the block?
Martin Becker
@Thermatix
Aug 20 2015 11:22
one moment, having weird issue, need to reset-server
huh
ok so I moved them out of the before_mount block and now it's sorta working? I mean the error's differant and just as oodd but the "undefined method" has gone away
I guess it's a bug with react.rb
Martin Becker
@Thermatix
Aug 20 2015 11:32
so yeah, moving the define_state out of the before_mount block makes the problem go away, the current problem is a validation issue, something unrelated.
guess I'll go bug them then, thanks
Elia Schito
@elia
Aug 20 2015 11:33
:+1:
Martin Becker
@Thermatix
Aug 20 2015 11:46
Actually, I take it back, It has to be in a before_mount block the problem is weird though, It says that it's undefined for App but the actual code that causes the problem is in a separate class called Spinner. It's very odd
meh.
@meh
Aug 20 2015 11:52
Thermatix, can you try on master?
Martin Becker
@Thermatix
Aug 20 2015 11:55
which version is master?
nvm I'll clone and install it
Martin Becker
@Thermatix
Aug 20 2015 12:01
Ok, just updated to v0.9.0-dev
and it's still complaining
huh, is it me or is the backtrace in the JS console more human readable?
no wait, it is just me, I've been using the .min version >_<
meh.
@meh
Aug 20 2015 12:06
Thermatix, can you make a simple repo that showcases the problem?
so I can try and see if it's an Opal issue or not
Martin Becker
@Thermatix
Aug 20 2015 12:09
ok, give me a moment
Martin Becker
@Thermatix
Aug 20 2015 12:29
https://github.com/Thermatix/sprockets_problem and then switch to branch "undefined_method_define_state"
follow the notes
and then just run ./executable
afk, need foooods
Martin Becker
@Thermatix
Aug 20 2015 12:43
back
Mitch VanDuyn
@catmando
Aug 20 2015 12:57
@thermatix - pretty sure this is a react.rb issue - lets move it over there...
meh.
@meh
Aug 20 2015 12:58
catmando, yeah
I've been digging
App does not have define_state
Torsten Rüger
@rubydesign
Aug 20 2015 12:58
@meh nice, that scanner method got me a step closer. But now i get the next missing one, skip_until
NoMethodError: undefined method `skip_until' for #<StringScanner:0x1bb8>
meh.
@meh
Aug 20 2015 12:58
dancinglightning, update again
I implemented all the missing methods
now it's barfing over a compilation issue
Torsten Rüger
@rubydesign
Aug 20 2015 12:59
did update 5 minutes ago
meh.
@meh
Aug 20 2015 12:59
dancinglightning, sometimes the stdlib stuff is broken, no clue why
reinstall the gem
it's probably caching some stuff it shouldn't
Torsten Rüger
@rubydesign
Aug 20 2015 12:59
working off the cloned opal rep
and there doesn’t seem to be a skip_until in there
meh.
@meh
Aug 20 2015 13:01
git show | head -n 1
bundle exec bin/opal -e 'require "strscan"; puts StringScanner.new("1 2 3 4").scan_until(/3/)'
commit 51812b101b6f3675b21ab46701afee925b9c85d8
1 2 3
Torsten Rüger
@rubydesign
Aug 20 2015 13:04
@meh i got that commit, yes. The error was skip_until , not scan_until. I see the scan_until, but not the skip_until. Should be trivial though (for you :-)
meh.
@meh
Aug 20 2015 13:04
ah
welp
yeah, I just read _until :P
dancinglightning, do you think you'd be able to figure out somehow what StringScanner methods parslet is using?
so we don't do a back and forth of fixing and I just add all required methods
Mitch VanDuyn
@catmando
Aug 20 2015 13:05
@meh - so you are saying if you subclass a class in which React::Component has been included, the define_state method does not follow along? I am pretty sure that we do this all over the place. Let me check.
meh.
@meh
Aug 20 2015 13:06
catmando, I don't know, I stopped digging when you said it was a react bug :P
Torsten Rüger
@rubydesign
Aug 20 2015 13:06
@meh i’ll have a look, but ruby being dynamic , . .
meh.
@meh
Aug 20 2015 13:06
dancinglightning, yeah, I know :P
catmando, what I saw is that App doesn't have that method defined
catmando, if you can give me a very small reduced testcase in just one file I can fix it, if it's an opal bug
Martin Becker
@Thermatix
Aug 20 2015 13:14
why would App not have define_sate?
meh.
@meh
Aug 20 2015 13:15
no clue
Torsten Rüger
@rubydesign
Aug 20 2015 13:16
@meh, i see scan , rest_size, check_until , string , pos , pos= , match? , check_until , exist? , skip_until . It only instantiates scanners in 2 places, and uses surprisingly little methods actually, considering it’s a parser generator
meh.
@meh
Aug 20 2015 13:16
dancinglightning, cool, thanks
Torsten Rüger
@rubydesign
Aug 20 2015 13:17
@meh cool would be if you could actually get parsley to work. I’d have the whole vm with interpreter in the browser.
Martin Becker
@Thermatix
Aug 20 2015 13:17
whats parsley?
meh.
@meh
Aug 20 2015 13:18
dancinglightning, well, I'm planning to replace the Ruby parser abomination we have in Opal with a parslet parser, so yeah :P
Martin Becker
@Thermatix
Aug 20 2015 13:18
question answerd
Torsten Rüger
@rubydesign
Aug 20 2015 13:20
@meh I’ll help: you do know i have the start of a ruby parser? I mean that that is ruby i am trying to parse in my app.
meh.
@meh
Aug 20 2015 13:20
dancinglightning, I didn't know
Torsten Rüger
@rubydesign
Aug 20 2015 13:21
https://github.com/salama/salama-reader i have kept it free off dependencies for exactly this kind of scenario
check out the tests, it can already do a fair bit
Martin Becker
@Thermatix
Aug 20 2015 13:29
@dancinglightning should've called it salami XD
Torsten Rüger
@rubydesign
Aug 20 2015 13:36
@Thermatix sorry, you might have to explain that reference
btw parsley is misspelled parslet, a peg parser (kind of generator)
Martin Becker
@Thermatix
Aug 20 2015 13:40
no reference just salama looks like salami
was a minor joke,
nothing meant by it
Torsten Rüger
@rubydesign
Aug 20 2015 13:41
ok
meh.
@meh
Aug 20 2015 13:41
dancinglightning, try with master
Martin Becker
@Thermatix
Aug 20 2015 13:41
btw, salama , i'm guessing it's used to build a VM based language like java?
Torsten Rüger
@rubydesign
Aug 20 2015 13:44
@Thermatix close, i am building a compiling vm for ruby (in ruby) :-)
Torsten Rüger
@rubydesign
Aug 20 2015 13:51
@meh thanks for trying, but it looks like i’s in an infinite loop. Not responding, no output, asks to kill the page after a while. The actual parse is small and works in my ruby tests.
meh.
@meh
Aug 20 2015 13:51
dancinglightning, can you break and find where the infinite loop is?
Martin Becker
@Thermatix
Aug 20 2015 13:51
lol yo dog, I heard you like ruby so I put some ruby in your ruby so you can compile some ruby XD
Torsten Rüger
@rubydesign
Aug 20 2015 13:52
@meh, don’t know how :-(
meh.
@meh
Aug 20 2015 13:53
dancinglightning, do an opal -c file.rb and give me the output
I'll do the debugging
Torsten Rüger
@rubydesign
Aug 20 2015 13:58
@meh i’m using opal server (with Opal.use_gem) and pull in the whole salama gem. Opal -c says some file not found (doesn’t say which, but i guess salama)
meh.
@meh
Aug 20 2015 13:59
dancinglightning, then download the generate .js and upload it somewhere
I just need the compile blob
or if you're using opal server and chrome
open the developer tools
in the debugger there's a pause icon
click that
and it should stop the execution and start the debugger in there
but since it could be a bug somewhere outside StringScanner
giving me the blob would be a better idea, or making a repo to make it run myself
Torsten Rüger
@rubydesign
Aug 20 2015 14:00
@meh i never get to a page to open dev tools, it just hangs. I can check in and you can clone
meh.
@meh
Aug 20 2015 14:00
fine by me
Torsten Rüger
@rubydesign
Aug 20 2015 14:18
@meh it’s done https://github.com/salama/salama-debugger on branch diy-render . Please understand that i was in the middle of an experiment there and the app doesn’t actually do anything. But it’s pure opal (as opposed to master which is volt) and has the bug in there. Possibly creating a simple app with just salama-reader is simpler for you. Still, good luck
meh.
@meh
Aug 20 2015 15:07
dancinglightning, ok, I reduced it to a loop in Parslet::Atoms::Repetition#try
now I just have to figure out what alignment of stars causes it to explode
because a basic parslet parser is working
guess that's something
Torsten Rüger
@rubydesign
Aug 20 2015 15:18
meh can you run parslets own tests under opal?
meh.
@meh
Aug 20 2015 15:19
I think that would be hard
Torsten Rüger
@rubydesign
Aug 20 2015 15:20
My grammar may be kind of sub optimal for testing. It has some ways of hanging that i haven't figured. Try the parslet example directory.
meh.
@meh
Aug 20 2015 15:22
yeah, looks enough
the comments.rb thing hangs
it's small enough
Martin Becker
@Thermatix
Aug 20 2015 15:36
umm remind me but does exec work in opal?
exec*
meh.
@meh
Aug 20 2015 15:37
no
maybe on node, dunno, but why would you be using node with Opal when you have MRI, Rubinius and JRuby
Martin Becker
@Thermatix
Aug 20 2015 15:40
node?
i'm not using node
I mean
in opal you have ```` and %x{}
...
back ticks and %x{}
wouldn't exec do the same but for a variable or normal string and convert it to raw javascript?
meh.
@meh
Aug 20 2015 15:43
Thermatix, you want eval
just include opal-parser
Torsten Rüger
@rubydesign
Aug 20 2015 15:48
@Thermatix maybe you want to check out native module too http://dev.mikamai.com/post/79398725537/using-native-javascript-objects-from-opal
meh.
@meh
Aug 20 2015 15:49
Thermatix, but yeah, why do you need eval? it's usually a sign you're doing something wrong
meh.
@meh
Aug 20 2015 16:23
@dancinglightning yeah, I'll drop it for now, debugging that mess is way harder than I expected
I'll try making StringScanner as compliant as possible
and hope for the best
although there is probably a compilation error in there
with a non-catched return
Torsten Rüger
@rubydesign
Aug 20 2015 16:39
@meh ok, when you’re done i can try and go through the parslet test and have a look. I don’t think it’s far off.
meh.
@meh
Aug 20 2015 16:40
dancinglightning, it's either a compiler bug, or a bug in StringScanner
but it's probably the former :(
the compiler is a total mess