asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.0 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
asterite has quit [Ping timeout: 246 seconds]
ismaelga has joined #crystal-lang
bcardiff has joined #crystal-lang
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
knoopx has joined #crystal-lang
knoopx has quit [Remote host closed the connection]
knoopx has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
waj has quit [Quit: Leaving.]
knoopx has quit [Remote host closed the connection]
ismaelga has quit [Remote host closed the connection]
weskinner_mac has joined #crystal-lang
weskinner_mac has quit [Quit: weskinner_mac]
canhtak has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
canhtak has quit [Quit: canhtak]
leafybasil has joined #crystal-lang
waj has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/AqI6
<crystal-gh> crystal/master 6a26913 Ary Borenszweig: Added a DayOfWeek enum, and made Time#day_of_week return that type. Also added Time#monday? and other methods for convenience.
<crystal-gh> crystal/master a5c22f9 Ary Borenszweig: Allow getting a type's constants in macros
<travis-ci> manastech/crystal#2022 (master - a5c22f9 : Ary Borenszweig): The build was fixed.
waj has quit [Quit: Leaving.]
canhtak has joined #crystal-lang
waj has joined #crystal-lang
ismaelga has joined #crystal-lang
bcardiff has joined #crystal-lang
asterite has joined #crystal-lang
weskinner_ has joined #crystal-lang
asterite has quit [Read error: Connection reset by peer]
asterite has joined #crystal-lang
<jhass> asterite: what do you think about autosplatting tuples in block arguments? def foo yield {:a, :b}; end; foo {|a, b| }
<asterite> jhass: That's something I want, but it's not trivial to implement
<jhass> k, figured. Thanks
<asterite> Well, "not trivial" is not correct… maybe I need a rest from thinking about new features :)
<jhass> would explicit destructering make it easier? foo {|(a, b)| } ?
<jhass> could even be a syntax rewrite to foo {|__tmp| a, b = __tmp } I guess
<jhass> or something like that
canhtak has quit [Quit: canhtak]
<jhass> btw I kind of dislike that shadowing a local with a block arg is a syntax error, I happen to do that intentionally quite often somehow :P
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/AYTA
<crystal-gh> crystal/master cf7afcf Ary Borenszweig: Changed Range(B, E) to Range(T)
<asterite> I think me too, and it annoys me too :(
<asterite> We'll probably change it, I have to check with waj
<asterite> Probably something breaks if we allow it, though
<asterite> jhass: what are you coding?
<jhass> still hacking a bit on crystal-gobject
<waj> I agree to that too…. it happened to me a lot while testing with libuv callbacks
<jhass> generated me this lovely snippet: PointerIterator.new(__return_value) {|__item| PointerIterator.new(__item) {|__item| raise "Expected string but got null" unless __item; String.new(__item) } } :P
<asterite> So it's settled, we don't want the "block argument shadows…" error anymore, right? :)
<jhass> \o/
<jhass> ruby does make it a warning if your run ruby -c btw
<jhass> but I think it's not so bad
<jhass> (or was it ruby -w o ruby -wc? something like that9
<jhass> do you have something in the compiler to generate me unique temporary locals that I can steal? :P
<jhass> names for them that is
<asterite> jhass: of course we have, we use it all the time
* asterite whispers but you can't access that from the language
<jhass> :(
<asterite> :(
<jhass> :P
<asterite> We'll probably need a macro method for that, I think I needed that too
<jhass> mmh, won't help me anyway, I'm literally do File.open "wrapper_for_#{foo}.cr" do |io| io << "module #{foo}" and so on
<jhass> item = "__item_#{rand(100)}" good enough for now :P
<asterite> :o
<travis-ci> manastech/crystal#2023 (master - cf7afcf : Ary Borenszweig): The build passed.
canhtak has joined #crystal-lang
<jhass> wait, module Foo; require "./bar"; end; scopes bar's contents into the module?
<asterite> jhass: yes
<jhass> any way to work around that?
<asterite> You put it outside the module :)
<jhass> meh
<asterite> Is that autogenerated?
<jhass> then I have to duplicate the module generation code I guess
<jhass> yeah
<asterite> We might "fix" that later (but right now it's supposed to work like that)
<jhass> what would happens with requrie 'foo'; module Bar; require 'foo'; end; ?
<asterite> Yeah, that's why it's not a great idea. Only the first one will do something
<asterite> the second one will be ignored by the compiler
<jhass> I've seen people demanding it for Ruby though, maybe make it available as include_file or something
<asterite> load doesn't work like that?
<asterite> We have this (choose an adjective) piece of code: https://github.com/manastech/crystal/blob/master/src/crystal/project_cli.cr#L6
<jhass> oO
<asterite> Not very nice, I guess
<jhass> why not call the compiler with a different prelude?
<jhass> anyway, maybe load does currently, but I'd remove that ability from require/load and move it to its own directive to make the distinction clear, for both sides
<asterite> Yes, that's probably a good idea
canhtak has quit [Quit: canhtak]
shama has joined #crystal-lang
<jhass> asterite: http://paste.mrzyx.de/pvb2rcy2l possible to make work without declaring c_handler as Void* ?
<jhass> and error out when passing a closure
<asterite> Well, I think in that case you have to do the check
<asterite> if callback.closure? …
<jhass> yeah, well, do what then?
<jhass> it works if I declare c_handler as Void* btw
<jhass> (well, sort of, something segfaults then, but I had it working like that)
<jhass> yeah, segfault seems unrelated
<asterite> raise "can't send closure to C" if callback.closure?
<asterite> Oh, I see what you mean
<jhass> but I can!
<asterite> You can try doing Callback.new(callback.pointer, Pointer(Void).null)
<asterite> and passing that
<asterite> maybe?
<jhass> ah, looks interesting, let me try
<jhass> yup, looks like that works, thanks!
<asterite> \o/
<jhass> now on to see how I introduced a segfault in Gtk::Window@Gtk::Container#add<Gtk::Window, Gtk::Widget>:Void (in /home/jhass/projects/crystal-gobject/gtk_hello_world) ;D
leafybasil has quit [Remote host closed the connection]
bcardiff has quit [Quit: Leaving.]
<jhass> mmh, is there a way to see the code a macro generates?
leafybasil has joined #crystal-lang
<jhass> asterite: can't cast (Pointer(LibGtk::Builder) | Pointer(LibGObject::Object)) to Pointer(LibGtk::Builder) you should add a trace for where either comes from to that
<jhass> if possible
<jhass> mmh, I think I broke type interference there
<asterite> :o
<asterite> You can see what a macro generates
<asterite> Just put `1 + ` before the end of it ;)
<jhass> heh :P
<jhass> I just called to_unsafe.foo to get a trace for the last one :P
<jhass> but I only get one for Pointer(LibGtk::Builder) :/
<jhass> can't figure out where the Pointer(LibGObject::Object) comes from :/
<asterite> Well, then that's something we definitely need to improve
<asterite> Can you add an issue so I don't forget?
<asterite> You can try restricting methods with types, until you find the place where you create that type
bcardiff has joined #crystal-lang
<jhass> I'm trying
<jhass> somehow I do inherit the other constructor that still allows it
<jhass> or I really broke type interference
<asterite> If you are inheriting, the instance variables types are shared across the hierarchy
<asterite> Well, they are shared between ancestors, not between siblings (unless the parent has that same instance var)
<jhass> ah, that might be it :/
<jhass> will a generic module help?
<asterite> I don't know without knowing that the code looks like
<jhass> I'll try
<asterite> but I guess you have some base GObject and a Builder < GObject ?
<jhass> not quite, I'm trying to extract the common stuff like constructor & to_unsafe into a module. Currently I include the module if the type has no parent
<jhass> so Gtk::Builder inherits GObject::Object which includes WrappedType which defines the constructor and to_unsafe
<jhass> but defining those via the included & inherited macro's makes no difference
<jhass> I guess I need to completely generate those for each class independently and randomize the instance variable name :/
<jhass> asterite: what exactly is @type in the included macro? can I call identify on it?
<jhass> ah, .name.identify.id works
<asterite> @type is a TypeNode, it's a fake ast node that has a linked type
<asterite> You can ask the name, instance vars, constants… for now
<asterite> Ah, subclasses too
<jhass> kay, I progressed from compile time to run time error :P
<jhass> managed to generate "Expected GObject::Object but got GObject::Object" ...
<asterite> :o
<jhass> it's what you get for nesting macro inherited into macro included :P
<jhass> and forget to escape the {{@type}}
<asterite> lol
<asterite> I think… you are abusing macros
<asterite> Maybe we should remove them from the language :D
<asterite> It works for java just fine
<jhass> heh, at least I generate you some few klocs of code that actually puts the compiler to a bit stress :P
<jhass> Java has reflection
<asterite> True. But how can you avoid the `int getFoo() { return foo; }` ?
<asterite> Um, `public int getFoo() { return foo; }`
<jhass> dunno and don't care much
<jhass> not using java has its reasons :P
asterite has quit [Quit: Leaving.]
waj has quit [Quit: Leaving.]
waj has joined #crystal-lang
<weskinner_> trying to run an http server in evented mode but seem to have the wrong libgc installed:
<weskinner_> main_module:(.text+0x597): undefined reference to `GC_get_push_other_roots'
<weskinner_> main_module:(.text+0x601): undefined reference to `GC_set_push_other_roots'
<weskinner_> main_module:(.text+0x606): undefined reference to `co_thread_init'
<weskinner_> sudo apt-get install libgc-dev says I already have it installed
<weskinner_> I guess I've got an old / different version of libpcl too
waj has quit [Quit: Leaving.]
<jhass> Travis should run Ubuntu too iirc, check the .travis.yml in the repo
weskinner_ has quit [Ping timeout: 245 seconds]