asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.1 | 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
willlll has joined #crystal-lang
<willlll> Hey, just came across this project earlier in the week. It looks really cool. Drive by suggestion, I’d love to see keyword arguments. I’d also love to see a lightweight syntax for blocks like smalltalk’s [ ] so you can easily pass more than one block to a method
<a5i> willlll: You can always submit an issue to the repo so more people can hear you
<willlll> that makes sense, I’ll do that thanks
<a5i> anytime
<jhass> willlll: keyword arguments are sort of there
<jhass> you can pass regular arguments as keywords
<jhass> >> def foo(a, b); {a, b}; end; foo(b: 1, a: 2);
<DeBot> jhass: Error in line 3: wrong number of arguments for 'foo' (0 for 2)
<jhass> mh, at so I thought
<jhass> >> def foo(a=1, b=2); {a, b}; end; foo(b: 3, a: 4);
<DeBot> jhass: {4, 3}
<jhass> for default arguments at least
<willlll> I was going to send a message to the mailing list, but my google admin (me) hasn’t apparnetly set up joining google groups and I’m on a plane, so I just popped in here. :)
<a5i> does Crystal have explicit return types?
<willlll> that’s cool jhass. Coming from ruby, the requried keyword args in 2.1 has been surprisingly awesome
<jhass> willlll: yeah, though I kinda like the idea of it being a caller only thing
<jhass> we should support it for regular args too
<a5i> :[
<jhass> >> def foo(a=, b=); {a, b}; end; foo(b: 3, a: 4);
<DeBot> jhass: Syntax error in eval:3: unexpected token: ,
<jhass> worth a try :P
<a5i> like
<a5i> fn foo() -> Bool
waj has joined #crystal-lang
havenwood has quit []
<a5i> jhass ?
<jhass> apparently not
<jhass> I'm not sure why you're asking for all that type restrictions, after all the whole damn point of Crystal is to have to specify as few as possible
<a5i> it's all a matter of curiosity
<jhass> read through spec/, you'll get a decent idea about the current state
<jhass> it's how I figure out stuff
<jhass> then you don't need to come up with all kinds of things all the time and then find somebody with an answer
<a5i> mk
waj1 has joined #crystal-lang
waj has quit [Read error: Connection reset by peer]
harisamin has quit [Quit: Textual IRC Client: www.textualapp.com]
waj1 has quit [Client Quit]
strcmp1 has quit [Quit: Leaving]
DerisiveLogic has quit [Read error: Connection reset by peer]
DerisiveLogic has joined #crystal-lang
ponga has joined #crystal-lang
ponga has quit [Client Quit]
willlll has quit [Quit: willlll]
waterlink1 has joined #crystal-lang
waterlink has quit [Ping timeout: 256 seconds]
waterlink1 has quit [Ping timeout: 248 seconds]
ponga has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
havenwood has joined #crystal-lang
shama has quit [Remote host closed the connection]
strcmp1 has joined #crystal-lang
shama has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
genericpenguin has joined #crystal-lang
<genericpenguin> hello people. I was wondering if anyone was working on any GUI toolkit libs for Crystal? Probably a stretch at this point but just asking in case anyone is.
bcardiff has quit [Ping timeout: 248 seconds]
JBat has joined #crystal-lang
bcardiff has joined #crystal-lang
<strcmp1> genericpenguin, Hey, I'm not, but I've seen a few graphics libraries being wrapped already, there is jhass/crystal-gobject. manastech/crocoa, and at least one other i can't remember the URL for :) those links are relative to github.com btw.
a5i has quit [Quit: Connection closed for inactivity]
bcardiff has quit [Quit: Leaving.]
BlaXpirit has joined #crystal-lang
<jhass> genericpenguin: http://crystalshards.herokuapp.com/
<BlaXpirit> how can it work?
<BlaXpirit> is it manually curated?
<jhass> no, Github API ;)
DerisiveLogic has joined #crystal-lang
<BlaXpirit> geez, SDL bindings are such a mess
<BlaXpirit> are any of them even usable?
<BlaXpirit> doesn't appear any of them are even close to complete
<strcmp1> i don't think even the ruby version does the time scale stuff
<strcmp1> but its been a while :)
<BlaXpirit> lol
JBat has quit [Quit: Computer has gone to sleep.]
DerisiveLogic has quit [Ping timeout: 245 seconds]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
colorados has quit [Quit: Leaving]
JBat has joined #crystal-lang
waterlink has joined #crystal-lang
<jhass> mmh, I'm evil http://paste.mrzyx.de/pemgulc5k
asterite has joined #crystal-lang
<asterite> jhass: Very evil! I didn't know %context would work in those position
<jhass> hehe
<jhass> I just tried and it did :D
<jhass> how do you like my infecting included hook? :D
<asterite> You mean line 110?
<asterite> I just lol'd at it
ponga has quit [Remote host closed the connection]
<jhass> yeah
<asterite> What does that do??
<asterite> Well, it's good you are squeezing the language to its maximum :)
<jhass> define self.run on all modules the module is included to and all modules those modules are included into and all.... and so on
<asterite> Why do you need the recursive inclusion?
<asterite> I also see you used previous_def
<asterite> But calling super in a module would also work, I was thinking... right?
<jhass> I use super too :D
<asterite> (when I'll fix the bug, which I was doing some minutes ago)
<asterite> How you are using it if it's not working?
<jhass> so, the before/after hooks by redefining a method on the context module, appending contents to it with previous_def
<waterlink> jhass: I like that thingy. It totally adds before, after and let - the things I have been missing
<jhass> and the initial definitions call super to include the hooks of the parent context module
<waterlink> asterite: how about cleaning up this code a bit and including it in crystal?
<jhass> yeah, totally needs cleanup
<jhass> I had the idea and it's an experiment to see whether it would work out
<asterite> If you can rewrite the specs in crystal's repo to use this new code, I think chances are very high that we'll switch to it
havenwood has quit [Remote host closed the connection]
<waterlink> We will need some huge test suite for that probably )
<asterite> Well, there are 5638 specs in crystal's repo ;)
<waterlink> The thing is that, it is probably compatible with Spec
<jhass> so the main features of that concept are: global namespace pollution down to 2 constants, hooks and instance variable sharing with the hooks and examples
<jhass> which is what I attempted in the past with my other approach too
<jhass> oh and example execution randomization
<asterite> What made it work this time?
<asterite> Maybe the %context thing?
<jhass> that and being able to put each example into its own class with it
<jhass> which was the idea that sparked the approach, putting each example into its own class
<waterlink> I'm interested how it will impact performance of crystal test suite
<waterlink> it will create 5.5K+ classes
ponga has joined #crystal-lang
<jhass> yeah
<jhass> plus a couple hundred modules
<waterlink> yeah
<strcmp1> haha
<strcmp1> definitely evil :P
<jhass> asterite: if #563 is an easy fix that'll ease cleanup :)
<waterlink> jhass: do you want to try to replace Spec with this code and see how it goes ?
<jhass> I still have to see if I can allot time to it tbh
<waterlink> Because I can try it now, I have some time
<jhass> oh, feel free
<waterlink> ok
<jhass> I need to make some food anyway and won't be useful until that's done ;D
<jhass> there's probably a way to get rid of the both Container classes, I always forget how and didn't bother so far
<jhass> the other issue is (and I think it's caused by the containers) that redefine_main has to sit below the examples, at lest when they're in the same, I didn't investigate yet if it works if broken into multiple files
<jhass> *in the same file
<asterite> I'm guessing this will take a lot of time to compile, but you can try :)
<asterite> #563 should be very easy to fix, yes
<BlaXpirit> oh i ran into this
<BlaXpirit> in the end, i made my own different aliases for each value
<waterlink> is there some sort of exit trap in crystal?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<waterlink> so you can trap exit and run spec
<asterite> There's at_exit { ... }
<waterlink> yeah, my linux box barely can compile test suite.. I doubt I will be able to compile it with this update at all. Lets see
<jhass> asterite: mmh, could we allow class/module reopening with an alias?
<jhass> alias B = A; module B; def foo; previous_def; more_code; end; end;
Ven has joined #crystal-lang
<asterite> jhass: yes, an (non-recursive) alias should just work in any place where the aliased type would
<BlaXpirit> jhass, yes, that's a great idea
<BlaXpirit> and while we're at it
<BlaXpirit> you should be able to add methods only to an ALIAS of a C lib struct
<BlaXpirit> although that may be even more difficult
<BlaXpirit> but yeah, this is my top feature request right now - being able to add things to lib types
<asterite> I have a secret (just found it today): try doing struct LibFoo::Bar; add_methods_here; end
<asterite> That is, outside the lib declaration
<asterite> It works for structs and unions :-)
<BlaXpirit> wuuuuuuuuuuuuut
<BlaXpirit> that's cool
<BlaXpirit> does it work on an alias?
<asterite> But I still have to reply to that issue (just that there's so much activity lately, I can't catch up!)
<asterite> Not sure it works on an alias because of what jhass said
<BlaXpirit> right, right
<BlaXpirit> well that's amazing
<asterite> At one point c structs didn't inherit Struct, but after I made that change I also accidentally allowed adding methods to structs/unions like that :-P
ponga has quit [Remote host closed the connection]
<asterite> (but I'll fix it soon, it should be easy)
<jhass> so if Alias::CONSTANT, module/class Alias::Foo and ideally module/class Alias works I think it's possible to get down to 2-3n modules/classes where n is the number of describe blocks
<jhass> oh, something else I noticed, but I guess asterite knows already :P
<jhass> >> module A; end; A.class
<DeBot> jhass: Class
<asterite> Should be Module?
<jhass> yeah
<asterite> I guess we can do that. Do you need it now?
<jhass> there's no need, it's just some inconsistency
<jhass> since it's all faked :D
<asterite> Hehehe, exactly :-)
<asterite> but if you want to add a method to all classes but not all modules, you can't do that right now... I guess
<asterite> >> class Class; def foo; 1; end; end; Int32.foo
<DeBot> asterite: 1
<jhass> >> class A; end; A.is_a? Module
<DeBot> jhass: Error in line 3: undefined constant Module
<jhass> >> class A; end; A.is_a? Class
<DeBot> jhass: true
<jhass> at least! ;D
ponga has joined #crystal-lang
<waterlink> jhass: asterite: what does %context and %example in macro do?
<jhass> get unique identifiers
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vfq2g
<crystal-gh> crystal/master fa76862 Ary Borenszweig: Fixed #556: super inside a module didn't work
<crystal-gh> crystal/master 0470050 Ary Borenszweig: Fixed: allow reopening type through alias
<crystal-gh> crystal/master 88ed201 Ary Borenszweig: Fixed #563: namespace resolution through aliases
<jhass> <3
<asterite> So they don't conflict with outside identifiers... I think that makes "hygenic macros" into the language, but not sure :-)
* jhass sometimes wonders if asterite actually does any paid work :P
<asterite> Well, enjoy ;-)
<asterite> jhass: I might have said this before, but thanks for being here and answering everyone's questions! You even point them to how primitives are implemented! :-)
* asterite wonders the same about jhass
<jhass> I'm still student ;)
<jhass> and I found this (helping others solve their problems) the most effective way to learn something, it's how I learned the ins and outs of Ruby ;)
<asterite> Amazing :-)
<asterite> How old are you?
<jhass> 23
bjmllr has joined #crystal-lang
<asterite> What are you studying?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<asterite> (I guess computer science :-P)
<waterlink> So I'm getting this error: no type inherits Spec2::ContextContainer(T)
<jhass> asterite: yup
<jhass> waterlink: yeah, that's the one I got when moving redefine_main above the examples :/
<waterlink> heh, but I'm trying to use at_exit at all..
<travis-ci> manastech/crystal#2249 (master - 0470050 : Ary Borenszweig): The build was broken.
<asterite> I think that error is a mistake, can't remember why I put that. Can you submit an issue? (with hopefully a reduced cast)
<asterite> case
asterite has quit [Quit: Page closed]
<waterlink> heh, I see
<waterlink> putting at_exit at the end of specs does the job
<jhass> waterlink: maybe try adding a fake spec context before it
<jhass> describe "nothing" do end; at_exit { ... }
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vfqKn
<crystal-gh> crystal/master 086746e Ary Borenszweig: Fixed #558: Array#push with incorrect type leads to stack overflow
<waterlink> will not work
<waterlink> the same with ExampleContainer
<waterlink> So one need to have fake example
<waterlink> too
<waterlink> or put fake Spec2.run at the end of describe macro :)
<waterlink> I could try do that
<waterlink> doesn't help
<jhass> mh, I'll try getting rid of the containers
<jhass> [] of Context:Class ? I think that was it
<jhass> >> module A; end; [] of A:Class
<DeBot> jhass: Syntax error in eval:3: unexpected token: Class
<jhass> meh
Ven has joined #crystal-lang
<jhass> >> module A; end; [] of A.Class
<DeBot> jhass: Syntax error in eval:3: expecting identifier 'class', not 'Class'
<jhass> >> module A; end; [] of A.class
<DeBot> jhass: []
<jhass> >> module A; end; class B; include A; end; X = [] of A.class; X << B
<DeBot> jhass: Error in line 3: no overload matches 'Array(A:Class)#<<' with types B:Class
<jhass> >> module A; end; class B; include A; end; X = [] of A.class; X << B.class
<DeBot> jhass: Error in line 3: no overload matches 'Array(A:Class)#<<' with types Class
<jhass> >> module A; end; class B; include A; end; X = [] of -> A.class; X << -> { B }
<DeBot> jhass: Error in line 3: no overload matches 'Array(( -> A))#<<' with types ( -> B:Class)
<jhass> >> module A; end; class B; include A; end; X = [] of -> (A.class); X << -> { B }
<DeBot> jhass: Error in line 3: no overload matches 'Array(( -> A))#<<' with types ( -> B:Class)
<waterlink> fake spec before makes it only run this spec
<jhass> >> module A; end; class B; include A; end; X = [] of Class.class; X << B.class
<DeBot> jhass: Error in line 3: no overload matches 'Array(Object+:Class:Class)#<<' with types Class
<jhass> waterlink: :/
<waterlink> and somehow twice..
<BlaXpirit> ooh neato. the bot does private messages
<jhass> >> module A; macro def childs; {{@type.subclasses}}; end; end; class B; include A; end; class C; include B; end; A.childs
<DeBot> jhass: Syntax error in eval:3: expecting token ':', not ';'
<jhass> wat
<BlaXpirit> is "macro def" a thing?
<jhass> yeah
asterite has joined #crystal-lang
<jhass> let me get an example
<BlaXpirit> jhass, don't bother
<BlaXpirit> i am not interested in this right now
<travis-ci> manastech/crystal#2250 (master - 086746e : Ary Borenszweig): The build has errored.
<BlaXpirit> was just guessing if u made a mistake there
<jhass> so it's instantiated in the context of a subclass if called on a subclass
<jhass> which gives you compile time access to the child class from the parent class
<jhass> if that makes any sense
<jhass> it's basically a macro to define a specific method on call on the type it's called on
<BlaXpirit> jhass, does {{ }} always just insert a string?
<jhass> the macro language is sort of like a templating language
<BlaXpirit> i know that it is sort of like
<BlaXpirit> what i'm asking is if it's exactly like
<waterlink> looks like I got it
<jhass> the normal code is inserted at the place you call the macro
<BlaXpirit> does the result of expression inside {{ }} always act as a piece of text and nothing more?
<jhass> {{}} calls into the compile time context and is replaced by the return value
<jhass> {% %} calls into the available control flow
<BlaXpirit> i know
<jhass> and yeah, it's pretty much just text replacement
<BlaXpirit> ok
<asterite> Yes, it just inserts a text
<waterlink> So I call `(@@run_lambda || -> {})` inside of `Spec2.run` and then in the end of `describe` macro replace `@@run_lambda` with proper call
<waterlink> lets see if it can handle multiple root contexts..
<BlaXpirit> so let me tell you this. sorry that i'm talking about a different language, but... in Nim such templates can be implemented without any modifications to the compiler
<asterite> There's just one special case and that's when you do {{ yield }}, that inserts the text but preserves the original block location, so the error messages are more useful… but that's it
<BlaXpirit> with just "userland" code.
<jhass> I broke the next thing :P
<jhass> >> module A macro def foo : Bool; true; end; end; class B; include A; end
<DeBot> jhass: nil
<jhass> heh
<jhass> >> module A macro def foo : Bool; true; end; end; class B; include A; end B.foo
<DeBot> jhass: Syntax error in eval:3: unexpected token: B
<jhass> >> module A macro def foo : Bool; true; end; end; class B; include A; end; B.foo
<DeBot> jhass: Error in line 3: undefined method 'foo' for B:Class
<jhass> mh
<jhass> bah, nvm, I fucked up
asterite has quit [Quit: Leaving.]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> meh, with asterite latest patches it segfaults now?
Ven has joined #crystal-lang
bcardiff has joined #crystal-lang
asterite has joined #crystal-lang
<asterite> jhass: something about the recursion with aliased types is breaking it, I'll fix it now
<jhass> http://paste.mrzyx.de/pt40wk46t would be my minimal example
<jhass> 88ed201ac4f2fe0763dceeb030ab6c11a5a47f62 broke it
<asterite> Thanks! I was going to try to reduce it :-)
<jhass> doesn't need the include actually
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vfqpM
<crystal-gh> crystal/master 817ba00 Ary Borenszweig: Fix indentation
<crystal-gh> crystal/master 93e5d32 Ary Borenszweig: Fixed: broken link attributes logic when aliases are involved
<jhass> <3, thanks!
<asterite> BlaXpirit: it's ok to talk about other languages, like Nim. We usually like to learn about many other languages and get inspiration from them, but of course we have our way to do things
<asterite> We try to keep things simple. I guess in Nim you can have arbitrary compile-time code execution?
<BlaXpirit> not completely arbitrary, but yes
<asterite> Those staticRead and writeFile happen at compile time?
<BlaXpirit> yes
<BlaXpirit> the executable does nothing :D
<asterite> Well, you can do the same with run in macros
<asterite> Well, not sure if the same, but it's close
<BlaXpirit> asterite, is this just string templating?
<BlaXpirit> you can't execute the string though, can you
<waterlink> So, when generating so much classes it is really deadly adding method on Object :) Deadly for memory while compiling
<asterite> I wonder why, adding a method to object shouldn't take long
<asterite> BlaXpirit: not sure what you mean, I think with `run` you can do many things
<BlaXpirit> don't see any information on it
<asterite> As many things, they are not yet documented because most of the things are expirmental until we find they are ok like that
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<asterite> waterlink: apart from the memory, does it take longer to compile?
<waterlink> Don't know
<waterlink> since my linux box starts swapping
<waterlink> and my X server freezes for minute or so
<waterlink> and that is only for one file )
<waterlink> but now when I put `fail` to macro instead of method
<waterlink> it is actually pretty ok
<asterite> That's why I'd like to keep the spec thing simple. There's also this: http://stackoverflow.com/questions/6453235/what-does-damp-not-dry-mean-when-talking-about-unit-tests , and I agree with that. When a test has a before_each and let and everything is dispersed everywhere it's very hard to follow what a test does
<jhass> I want example randomization at least though
<waterlink> then I'm fine with having spec2 as external library )
<waterlink> It is just when you use RSpec for quite some time, you can't go back to the world of simple unit tests..
<asterite> :)
<asterite> But, of course, that's my personal opinion and it's inevitable that other things will appear (and I like that!). There's already an initial minitest too
<waterlink> Compiling all_spec.cr doesn't seem to get more then ~900MB of memory now
<waterlink> but it is still not finished
<asterite> You mean, with spec2?
<waterlink> yes
<asterite> I think 900MB is what it consumes with spec too
<waterlink> It is already 915 :) so we'll see )
<asterite> Oh, I thought spec2 is not finished, not the run
<waterlink> I have tried already on couple of complicated spec files (like array_spec, markdown_spec, c_enum_spec) and it worked
<waterlink> ok, I got compilation error :)
<waterlink> because it is impossible to create classes inside blocks )
<travis-ci> manastech/crystal#2251 (master - 93e5d32 : Ary Borenszweig): The build passed.
Ven has joined #crystal-lang
<asterite> waterlink: in what spec?
<waterlink> special_vars_spec.cr
<waterlink> and when trying to convert it to macro
<waterlink> I got this
<asterite> Ah, well, yes, if "it" defines a class you basically can't do [1, 2, 3].each { |x| it "works with #{x}" }
<asterite> However you could do {% for x in [1, 2, 3] %} …
<asterite> but it's uglier :)
<waterlink> not too much
<waterlink> still, can you tell me what is wrong with macro in gist?
<waterlink> I see
<waterlink> it is `%(`
<waterlink> I need to escape it
<asterite> Probably the macro is parsing something that you need to escape (like you said) or a bug in the "end" counting
ponga has quit [Quit: Leaving...]
<waterlink> Ok, I will try {% for .. %} for now
ponga has joined #crystal-lang
shama has joined #crystal-lang
<waterlink> that worked
<asterite> Cool :)
<waterlink> Seems, that these `should` and `should_not` methods on `Object` are not the best idea in terms of memory during compilation
<waterlink> I think if we will be able to use `expect(..).to matcher` syntax, then we will win several hundreds of MBs
<waterlink> I might be wrong
<asterite> We can try
<waterlink> But that was my impression, when I added `fail` method there
ssvb has joined #crystal-lang
<waterlink> ok, next compile error: can't define module inside def :)
<waterlink> actually that is my spec :D
ponga has quit [Quit: Leaving...]
<waterlink> undefined local variable or method 'contents' (did you mean 'contents'?) ...
havenwood has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
<waterlink> already 1GB and still compiling (14 min)
<waterlink> what can be lighter then Class per example?
<waterlink> probably Object per example
<waterlink> of one class
<waterlink> so the question is, how to convert passed in block to a lambda?
<waterlink> >> -> {}.class
<DeBot> waterlink: ( -> Nil)
<waterlink> >> def some(&blk) blk.class; end
<DeBot> waterlink: nil
<waterlink> >> def some(&blk) blk.class; end; some {}
<DeBot> waterlink: ( -> Void)
<waterlink> >> def some(&blk -> Nil) blk.class; end; some {}
<DeBot> waterlink: Syntax error in eval:3: expecting token ')', not '->'
<waterlink> >> def some(&blk : -> Nil) blk.class; end; some {}
<DeBot> waterlink: ( -> Nil)
<waterlink> >> def some(lam, &blk : -> Nil) blk.class == lam.class; end; some -> {}, {}
<DeBot> waterlink: Syntax error in eval:3: for empty hashes use '{} of KeyType => ValueType'
<waterlink> >> def some(lam, &blk : -> Nil) blk.class == lam.class; end; some(-> {}) {}
<DeBot> waterlink: true
<waterlink> hmm
<waterlink> says that block and lambda is the same
<waterlink> >> class X; def initialize(@desc, &@bllk) end; def run; @blk.call; end; end; def it(desc, &blk) X.new(desc, &blk); end; x = it("does something") { puts "hello world" }; x.run
<DeBot> waterlink: in line 3: undefined method 'call' for Nil (@blk was never assigned a value, did you mean @bllk?)
<waterlink> >> class X; def initialize(@desc, &@blk) end; def run; @blk.call; end; end; def it(desc, &blk) X.new(desc, &blk); end; x = it("does something") { puts "hello world" }; x.run
<DeBot> waterlink: in /usr/lib/crystal/io.cr:339: undefined method 'inspect' for Void
bcardiff has joined #crystal-lang
<waterlink> >> class X; def initialize(@desc, &@blk) end; def run; @blk.call; nil; end; end; def it(desc, &blk) X.new(desc, &blk); end; x = it("does something") { puts "hello world" }; x.run
<DeBot> waterlink: hello world
<waterlink> hmm, ok
<waterlink> that could be a way
<waterlink> 21 minutes in. Still compiling :D
<asterite> I don't think that will work :)
<waterlink> Why ?
bcardiff has quit [Client Quit]
<waterlink> describe will create object of Context class and put it into root context registry
<waterlink> inner describe and context are methods of this root context
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
<waterlink> and they will create new instances of Context and put register it to current context owned registry
<waterlink> and Context has it method, which creates Example instance
<waterlink> and puts it into current context owned example registry
<asterite> I mean, I don't think the current approach will work if it takes >21 minutes to compile
<waterlink> Ah
<waterlink> this
<waterlink> yeah I already figured out :D
<waterlink> Ah
<waterlink> and it failed to compile
<waterlink> again some #each in specs
<asterite> Maybe it's something simple that can be optimized in the compiler, though, but I don't think so
<waterlink> Will not retry it
<waterlink> jhass: if you will want to play around with it, half working version is at my fork waterlink/smarter_spec
<jhass> thanks, tbh. I'm playing with a single class for multiple examples approach atm :)
<waterlink> Ok
<waterlink> no problem )
<jhass> I have a habit of throwing stuff away 2 - 3 when I'm experimenting :/
<jhass> * times
<waterlink> Yeah that is actually good thing )
<waterlink> So on master
<waterlink> Compiling specs takes 1:36 mins
<waterlink> and 1.4GB of RAM
<waterlink> I want to see if getting rid of `Object#should,#should_not` will help to improve that
vifino has quit [Remote host closed the connection]
vifino has joined #crystal-lang
<waterlink> Actual run took 3:04 mins and 1.6GB of RAM
<waterlink> on master
<waterlink> And it feels like during spec run GC doesn't kick in ? Is it true?
<waterlink> ram consumption was only increasing (instead of doing sort of down-up-down-up...)
<asterite> Once boehm GC allocates memory it never gives it back to the OS (I think)
<jhass> iteration 2: http://paste.mrzyx.de/p45nhkab4
BlaXpirit_ has joined #crystal-lang
<waterlink> jhass: so you put all of them as an unique-named methods to one class..
<jhass> yep and then have lambdas to invoke them
<jhass> and make a new instance of that class for each call
<jhass> to have a clean context
BlaXpirit_ has quit [Client Quit]
<waterlink> but you do have as much classes as you have contexts
<jhass> yes
BlaXpirit_ has joined #crystal-lang
<waterlink> might be actually not bad from performance point
BlaXpirit has quit [Ping timeout: 250 seconds]
<jhass> one module and one class per context
<waterlink> >> s = %( hello world "
<DeBot> waterlink: Syntax error in eval:7: unterminated string literal
<BlaXpirit_> can't take pointerof(self) :(
<BlaXpirit_> that is gonna complicate things a ton
<BlaXpirit_> should it be allowed maybe?
<asterite> You can assign it to a variable and take a pointer to that
<asterite> (there was a reason why pointerof(self) is not allowed, can't remember it though)
asterite has quit [Quit: Leaving.]
<BlaXpirit_> asterite, but if that copy is modified?
<BlaXpirit_> can't write self = copy, can i
<jhass> waterlink: meh, might not be worth it after all, I hacked up array_spec to run under it and pasted it a couple of times to get a 18kloc file, still bumps up to close to a GB RES and
<jhass> Parse: 00:00:00.3079000
<jhass> Type inference: 00:00:07.8077410
<jhass> Codegen (crystal): 00:00:03.0791330
<jhass> Codegen (bc+obj): 00:00:32.9864620
<jhass> Codegen (clang): 00:00:01.6888090
<waterlink> it is definitely worth it as a library for people to use
<waterlink> because lets, befores and afters will be very useful to them. And I doubt they will have such a big test suites as crystal itself )
<jhass> let's see, I pasted it another couple of times to get to ~33kloc, since spec/ is 35kloc
<jhass> Type inference: 00:00:15.8498200
<jhass> Codegen (crystal): 00:00:05.5665770
<jhass> Codegen (bc+obj): 00:02:03.0147400
<jhass> Codegen (clang): 00:00:03.5276880
<jhass> codegen blows up, interfence amazingly doesn't
<jhass> interestingly doing the same for stdlib spec (pasting array_spec into a file to get to a ~33kloc one) crashes the compiler
<jhass> mh, this time it doesn't
<jhass> Type inference: 00:00:05.8161470
<jhass> Codegen (crystal): 00:00:03.2885120
<jhass> Codegen (bc+obj): 00:00:13.4779560
<jhass> Codegen (clang): 00:00:00.2275330
<jhass> for the old one
<jhass> anyway, if you want to shape that into a proper library you're welcome to, I can't really justify dedicating too much time to it atm, but if you add me to the repo I might push some boilerplate every once in a while ;)
<jhass> the expectation stuff from https://github.com/jhass/crystal/tree/specs2/src/spec might actually be reusable for it, didn't check yet
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DerisiveLogic has joined #crystal-lang
zipR4ND has joined #crystal-lang
<zipR4ND> hi all, i would like to write a ssl client + server application that checks certificates and stuff, therefore i need a more complete binding of the openssl headers. i've been playing with crystal_lib_gen and managed to compile something, but it segfaults. has anyone already created better openssl bindings for crystal?
<BlaXpirit_> i can't find any
<jhass> http://crystalshards.herokuapp.com/ is a pretty complete list of Crystal projects, I don't see any TLS lib binding there
<jhass> so you might need to massage the generated binding a bit or backfil what's missing in the official binding by hand
<zipR4ND> jhass: that's what i feared ...
<zipR4ND> basically I need the ability to get the ssl certificate out of the socket
<zipR4ND> for server & client
<zipR4ND> i think it's get_peer_certificate in x509 https://github.com/openssl/openssl/blob/master/include/openssl/x509.h
<crystal-gh> [crystal] waterlink opened pull request #564: Spec : get rid of object patching (master...spec/get_rid_of_object_patching) http://git.io/vfYj0
ponga has joined #crystal-lang
<BlaXpirit_> I have a struct with an array
<BlaXpirit_> C lib struct
<BlaXpirit_> @arr[0] = says it's not initialized
<BlaXpirit_> @arr = [...] crashes
<BlaXpirit_> @arr = {...} might be it
<BlaXpirit_> nope. i think it appears to work but leaves them at zero!
zipR4ND has quit [Ping timeout: 272 seconds]
ponga has quit [Quit: Leaving...]
asterite has joined #crystal-lang
<asterite> BlaXpirit_: I saw in your readme that you talk about enums and that you can or them... I don't think you know about @[Flags] (not documented :-()
<BlaXpirit_> asterite, i read about something
<BlaXpirit_> that it enables ORing
<BlaXpirit_> but that it also works anyway for now
<BlaXpirit_> no immediate advantage from it or am i missing something
<asterite> Ah, yes, I think it works too
<asterite> Just a nicer to_s
<BlaXpirit_> ok
<BlaXpirit_> i can add trivially
<asterite> >> @[Flags]; enum Foo; A; B; C; end; Foo.new(5)
<DeBot> asterite: Sorry, that took too long.
<asterite> Yes
<asterite> >> @[Flags]; enum Foo; A; B; C; end; Foo.new(5)
<BlaXpirit_> o.o
<DeBot> asterite: Sorry, that took too long.
<asterite> >> 1
<DeBot> asterite: Sorry, that took too long.
<asterite> Maybe it's DeBot's lunch time
<BlaXpirit_> :>
<jhass> asterite: sorta, expensive migration running on my box :P
<BlaXpirit_> asterite, I added ": UInt32" anyway to those combinable enums
<BlaXpirit_> so yeah, trivially added @[Flags] as well
<BlaXpirit_> i was in the process of moving constructors inside structs as well, but it doesn't work well
<asterite> Yeah, constructors are like hijacked (special) right now for those things
<asterite> But maybe we can change things, I hope. We all want to simplify things :-)
<BlaXpirit_> have to stick with SF.video_mode(...) for now but would like to see SF::VideoMode.new(...) working without gotchas
<BlaXpirit_> i replied in the topic
<BlaXpirit_> you probably saw
<asterite> Yes, I saw it. I have some ideas, I'll write them down later. I'd also like to brainstorm it with waj
JBat has quit [Quit: Computer has gone to sleep.]
<asterite> By the way, I just tried the record sound sample and I was amazed it worked :)
DerisiveLogic has quit [Ping timeout: 256 seconds]
<BlaXpirit_> why wouldn't it
<BlaXpirit_> but strangely saving to file and playing back is deafening
<BlaXpirit_> playing in VLC, anyway
<asterite> I don't know, it's nice to have a complete game lib working in crystal :)
<BlaXpirit_> sure is
BlaXpirit_ has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
<jhass> asterite: mh, I need a quick refresher, any tip how I can quickly bind gethostname(3)
<jhass> ?
<jhass> that API is kinda f*cked up
<asterite> what do you mean?
<jhass> it wants you to pass an allocated buffer, you tell it how big that buffer is with the second param, it writes a 0 terminated string into the buffer (or as much as it can)
<jhass> it doesn't tell you how was actually written
<jhass> and the maximum hostname length is system configuration dependent apparently
<asterite> So ugly
<asterite> So how much you'll allocate?
<jhass> SO says POSIX says it has to be 255, so that's good enough
<jhass> but I'm not sure about what String API I should use
<jhass> do we have strlen mapped?
<asterite> Well, the most efficient way would be to do String.new(256) { |buffer| LibC.gethostname(buffer, 256); len = LibC.strlen(...) }
<asterite> Yes, it's in string.cr
<asterite> http://crystal-lang.org/api/String.html#new%28capacity%2C%20%26block%29-class-method
<asterite> (one thing that's documented! :-D)
<jhass> anchor is broken though :P
<jhass> works, thanks!
<asterite> Awesome!
cool_coder_forfo has joined #crystal-lang
<cool_coder_forfo> what is crystal dep 'frank'?
<cool_coder_forfo> no description on githu
<cool_coder_forfo> seesm simpe web handler
<jhass> yes, a very basic web framework ;)
<jhass> >> "1".succ
* jhass slaps DeBot
<DeBot> jhass: Sorry, that took too long.
<jhass> nope, not there :/
DerisiveLogic has joined #crystal-lang
genericpenguin has quit [Ping timeout: 246 seconds]
<asterite> Is String#succ used in real life?
<jhass> I just had a usecase for it
<jhass> Github switched its API so you can no longer fetch an auth token
<jhass> instead creating one you supply now an fingerprint
<jhass> if you try to create one with an existing fingerprint your get a 422 back
<jhass> so I put that it into loop with fingerprint.succ basically
<jhass> (I use the hostname as fingerprint and append -1, -2, -3 until it works)
<BlaXpirit> >> "a9".succ
<DeBot> BlaXpirit: Error in line 3: undefined method 'succ' for String
<jhass> ssvb: forgive my ignorance, but I wonder, what does C++ do on v32 = one + v64? implicit cast to int32?
zipR4ND has joined #crystal-lang
<BlaXpirit> >> {Int32, String}.class
<DeBot> BlaXpirit: Sorry, that took too long.
<BlaXpirit> >> {Int32, String}.class
<DeBot> BlaXpirit: Sorry, that took too long.
<ssvb> jhass: for the addition operation, it does not matter if we cast the int64 operand to int32 before addition or truncate the result to int64
<ssvb> jhass: with the other operations it may be probably different, but I haven't looked too deep into this yet
<jhass> just thought you might know offhand what C++ actually does in that case
<ssvb> Crystal can probably just mimic whatever is done by Clang for C++
<ssvb> it is unlikely to have any performance implications because C++ is supposed to be fast anyway :-)
<jhass> my question is about the behavior, you're saying the result of one + v64 is a 64bit integer, what happens if you assing that to a variable that's typed as a 32bit integer?
<ssvb> hmm, this is an interesting question
<asterite> I just tried it, it "works"
<ssvb> for C++, the end result is a 32bit integer because the variable type is explicitly declared as int32
<asterite> int x = 0; long y = 123456789123; x += y; ... print x and you get -1097262461
<ssvb> for Crystal, it might be not very nice to get an union of Int32 and Int64
<asterite> I think what ssvb proposes makes sense. For example if you add an Int32 with a BigInt the result is always a BigInt
Excureo has quit [Remote host closed the connection]
<asterite> I think it's no problem. Well, the problem is that if you have a variable of type Int32, say x, and you do x += y with y being Int64, x will become a union, but the result will be (if there's no overflow) correct. You will get a compile error if you try to put that into an array of Int32
<asterite> but you can always go and change x to be Int64 and you'll get the same behaviour plus a bit of performance
<asterite> I can't remember why right now a op b preserves a's type, maybe we didn't think about it enough
<asterite> (i think it's that way to avoid accidental unions)
Excureo has joined #crystal-lang
<ssvb> ok, I see
<asterite> There's also Rust's alternative, which basically disallows operations between distinct types
<asterite> But i think I prefer ease of coding and accidental unions which can always be profiled and fixed
asterite has quit [Quit: Page closed]
BlaXpirit has quit [Quit: Quit Konversation]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
a5i has joined #crystal-lang
cool_coder_forfo has quit [Ping timeout: 272 seconds]