jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.6 | Fund Crystals development: http://is.gd/X7PRtI | 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
<jhass> mmh
<jokke> looks the same to me
<jhass> yeah
<jokke> this is my fun: https://p.jreinert.com/kPu7M/
<jhass> mmh
<jhass> I don't remember if out zero's
<jokke> oh
<jokke> hmm
<jokke> ok
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vsyGD
<crystal-gh> crystal/master fde74a0 Ary Borenszweig: Fixed #1271: disallow dynamically declaring def, class and other declarations
<jokke> output is true\nfalse
<jokke> so something seems to happen with it
<Kilo`byte> >> nil.try { &.nil? }
<DeBot> Kilo`byte: Syntax error in eval:4: unexpected token: & - http://carc.in/#/r/cpu
<Kilo`byte> err fail
<Kilo`byte> >> nil.try &.nil?
<DeBot> Kilo`byte: # => nil - http://carc.in/#/r/cpv
<Kilo`byte> >> "test".try &
<DeBot> Kilo`byte: Syntax error in eval:11: expecting identifier 'end', not 'EOF' - http://carc.in/#/r/cpw
<Kilo`byte> >> "test".try {|t| t}
<DeBot> Kilo`byte: # => "test" - http://carc.in/#/r/cpx
<Kilo`byte> good
<travis-ci> manastech/crystal#fde74a0 (master - Fixed #1271: disallow dynamically declaring def, class and other declarations): The build passed. https://travis-ci.org/manastech/crystal/builds/77080840
<Kilo`byte> also i might look into mutexes for fibers
<jokke> awesome jhass
<jokke> works now
<jokke> jhass: do you think, i should just use crystal-gobject for my lib?
<Kilo`byte> >> class A; class B; end; end; B.new
<DeBot> Kilo`byte: Error in line 4: undefined constant B (did you mean 'A'?) - http://carc.in/#/r/cpy
<Kilo`byte> err
<Kilo`byte> >> class A; class B; end; end; A::B.new
<DeBot> Kilo`byte: # => #<A::B:0x81ceff0> - http://carc.in/#/r/cpz
<Kilo`byte> nice :D
<jhass> jokke: it certainly is not completed, would love to receive PRs with improvements though ;P
<jokke> jhass: from a guy who tries two hours to get the only function in his c bindings to work :D
<jhass> but it can generate itself (well bindings for gobject-introspection it used to generate them) and the libnotify binding seems to be solid
<jhass> oh and don't worry, I vaguely remember spending around 3 hours on that GError madness
<jokke> :)
<jhass> at the end of the day one's safest bet is translating examples such as https://developer.gnome.org/glib/stable/glib-Error-Reporting.html as literal as possible and hide that literal translation in a nice abstraction
<jhass> I guess
<jhass> >> (2**32 - 1) - (0xbefd1000 + (8 * 1024 * 1024))
<DeBot> jhass: # => 1.08232e+09 - http://carc.in/#/r/cq0
<jhass> >> "%d" % (2**32 - 1) - (0xbefd1000 + (8 * 1024 * 1024))
<DeBot> jhass: Error in line 4: undefined method '-' for String - http://carc.in/#/r/cq1
<jhass> derp
<jhass> >> "%d" % ((2**32 - 1) - (0xbefd1000 + (8 * 1024 * 1024)))
<DeBot> jhass: # => "1082322943" - http://carc.in/#/r/cq2
<jhass> plenty of addresses still too
<jhass> I don't get it
<jhass> but then I know shit about mmap
<Kilo`byte> wow that was like no work at all
<jokke> that's the best i could think of for now
<jhass> nice
<Kilo`byte> seriously, why doesn't every language use fibers
<jhass> might make sure the blocks return value is returned from the assert call
<Kilo`byte> they make your life piss easy
<jokke> jhass: you're right
havenwood has quit [Ping timeout: 265 seconds]
trapped has quit [Read error: Connection reset by peer]
elbow_jason has quit [Quit: Leaving]
<Kilo`byte> jhass: how do i mark a test as pending?
<Kilo`byte> just no pass a block to it?
<Kilo`byte> >> require "spec"; describe "stuff" do; it "is pending"; end
<DeBot> Kilo`byte: in line 4: 'it' is expected to be invoked with a block, but no block was given - http://carc.in/#/r/cq5
<Kilo`byte> apparently not
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
kori has quit [Ping timeout: 246 seconds]
<Kilo`byte> asterite: remember the crap regarding that weird exception that only happens on x86 from earlier
<Kilo`byte> i may just have reproduced that on x86_64
<Kilo`byte> https://github.com/RX14/fast-irc.cr - just run the specs
<Kilo`byte> commit 2344451615190a6e8963421e80d253518497f1e8 in case i add some commits before you see this
kori has joined #crystal-lang
DeBot has quit [Remote host closed the connection]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
kyrylo has quit [Ping timeout: 244 seconds]
bcardiff has joined #crystal-lang
willl has joined #crystal-lang
dylanmei has quit [Quit: ZZZzzz…]
dylanmei has joined #crystal-lang
dylanmei has quit [Quit: ZZZzzz…]
vonkingsley has joined #crystal-lang
vonkingsley has quit [Client Quit]
dylanmei has joined #crystal-lang
dylanmei has quit [Client Quit]
BlaXpirit has joined #crystal-lang
willl has quit [Ping timeout: 244 seconds]
willl has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
Ven has joined #crystal-lang
ssvb has quit [Ping timeout: 265 seconds]
havenwood has joined #crystal-lang
ssvb has joined #crystal-lang
sdogruyol has joined #crystal-lang
tatey_ has quit []
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<jokke> how would i recursively delete a directory?
Raimondii is now known as Raimondi
<jokke> i noticed there's no fileutils in the API
sdogruyol has quit [Ping timeout: 265 seconds]
sdogruyol has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
tatey_ has joined #crystal-lang
<jokke> hm
<jokke> i have a problem
<jokke> my c lib has a function xapian_database_close
<jokke> it takes a pointer to XapianDatabase
<jokke> i've mapped XapianDatabase to Void*
<jokke> XapianDatabase* to Void*
<jokke> there are also other functions like xapian_writable_database_new
<jokke> which return a XapianWritableDatabase*
<jokke> which i've also mapped to Void*
<jokke> now i have two classes XapianDatabase, and it's subclass XapianWritableDatabase
kyrylo has joined #crystal-lang
<jokke> i want XapianDatabase to have an instance method close which calls xapian_database_close with the pointer returned by xapian_(writable_)database_new
<jokke> but i crystal wont allow me to cast a WritableDatabase* to Database*
<jhass> in the parent define def to_unsafe; @pointer as XapianDatabase*; end; def close; LibXapien.database_close(self); end;
<RX14> Kilo`byte, are you around?
<jhass> in the subclass def to_unsafe; @pointer as XapianWritableDatabase*; end; def initialize; @pointer = LibXapian.writable_database_new; end
<jhass> mmh, actually not sure that works
<jhass> might need private def database; @pointer as XapianDatabase*; end; ... LibXapian.close(database) in the parent
leafybasil has joined #crystal-lang
<jokke> nope
<jokke> can't cast Pointer(LibXapian::WritableDatabase)? to Pointer(LibXapian::Database)
sdogruyol has quit [Remote host closed the connection]
DeBot has joined #crystal-lang
<jhass> make sure to resolve the nil-union first
<jhass> Pointer(LibXapian::WritableDatabase)? == Pointer(LibXapian::WritableDatabase)|Nil
havenwood has quit [Ping timeout: 252 seconds]
<jokke> i'm confused
<jokke> ah i think i understand
<jokke> hm
<jokke> this doesn't work either: in ./src/xapian/database.cr:21: can't cast (Pointer(LibXapian::WritableDatabase) | Pointer(LibXapian::Database)) to Pointer(LibXapian::Database)
<jhass> meh, might need to cast to Void* first
<jokke> :(
<jokke> woh
<jokke> wow
<jokke> can't cast (Pointer(LibXapian::WritableDatabase) | Pointer(LibXapian::Database)) to Pointer(Void)
<jokke> that sure is some type safety :D
Ven has quit [Ping timeout: 265 seconds]
<jhass> uh
<jhass> maybe it's still the union? :/
<jokke> that would be can't cast Pointer(LibXapian::WritableDatabase)? to Pointer(Void)
<jokke> right?
<jhass> no
<jhass> I think you just can't cast unions to things outside
<jhass> >> [1, "foo"].sample as String
<DeBot> jhass: Exception: cast to String failed - more at http://carc.in/#/r/cqz
<jhass> >> [1, "foo"].sample as Symbol
<DeBot> jhass: Error in line 4: can't cast (String | Int32) to Symbol - http://carc.in/#/r/cr0
<jhass> not how it's runtime vs compile time error
<jhass> *note
<RX14> >> [1, "foo"].sample as String
<DeBot> RX14: # => "foo" - http://carc.in/#/r/cr1
<RX14> >> [1, "foo"].sample as String
<DeBot> RX14: # => "foo" - http://carc.in/#/r/cr2
<RX14> >> [1, "foo"].sample as String
<DeBot> RX14: # => "foo" - http://carc.in/#/r/cr3
<RX14> >> [1, "foo"].sample as String
<DeBot> RX14: # => "foo" - http://carc.in/#/r/cr4
<RX14> uhu
<RX14> you would think it qould fail half the time
<jokke> oh
<RX14> or maybe i'm just lucky
<jokke> ok i see
<jokke> i still have no idea how to fix this..
<jokke> i wouldn't want to use Void* everywhere
<RX14> >> [1, "foo"].sample as String
<DeBot> RX14: # => "foo" - http://carc.in/#/r/cr5
<RX14> WHY
<RX14> >> [1, "foo"].sample as String
<DeBot> RX14: Exception: cast to String failed - more at http://carc.in/#/r/cr6
<RX14> YES!
<RX14> finally
<RX14> jesus
<Netfeed> >> "test" as Symbol
<DeBot> Netfeed: Error in line 4: can't cast String to Symbol - http://carc.in/#/r/cr7
<Netfeed> :(
<RX14> line 4?
<jhass> jokke: how about protected def to_database; (@pointer as LibXapian::Database); end; def close; LibXapian.close(to_database); end; in the superclass and def to_database; (@pointer as LibXapian::WritableDatabase) as LibXapian::Database; end; in the subclass
<jhass> RX14: click the link
<RX14> back to ircv3 parsing
<RX14> also the segfaults Kilo`byte got was because I didn't push my segfault fix...
<RX14> stupid me
<jhass> asterite: /cc ^
<jhass> for when he reads the backlog
<RX14> yeah the segfault was because of the :: unsafe I used
<RX14> i fixed it but forgot to push which lead Kilo`byte to get confused
<RX14> I thought I pushed it anyways
<RX14> but never mind
<RX14> it was my fault as I said yesterday
kyrylo_ has joined #crystal-lang
<RX14> yes! all the specs run, it's just time for ircv3 now
kyrylo has quit [Ping timeout: 252 seconds]
<jokke> jhass: awesome!
<jokke> works like a charm
<jokke> but i used to_unsafe instead of (@pointer as LibXapian::WritableDatabase)
<jokke> which is exactly that
<jokke> but i had to solve the union
<jhass> yeah
<jhass> I guess an alternative to casting is to use a different instance var in the subclass
<jokke> oh i need to define to_unsafe in Database still
<jhass> that would probably keep any casting out of the superclass at least
kyrylo_ is now known as kyrylo
sdogruyol has joined #crystal-lang
oal has joined #crystal-lang
<RX14> can you break out of 2 while loops, like tagged break in java?
<RX14> and i suppose C has that too?
<BlaXpirit> RX14, i don't think so
<RX14> yeah, oh well
<RX14> there isn't really in ruby eitheer
<BlaXpirit> RX14, return out of a function, yadda yadda
Ven has joined #crystal-lang
<jhass> >> Pointer(Void).new(0xffffffff) == 0xffffffff
<DeBot> jhass: # => false - http://carc.in/#/r/crb
<jhass> mmh
<BlaXpirit> not surprising
trapped has joined #crystal-lang
<RX14> hmmn, maybe I don't need nested while loops
<dzv> ruby has catch/throw that can be used to break out of multiple loops
<RX14> i wonder how efficient that is
<RX14> aparrently it also has continuations
sdogruyol has quit [Remote host closed the connection]
mrzyx has joined #crystal-lang
mrzyx has quit [Ping timeout: 250 seconds]
<BlaXpirit> i thought i could do this
<BlaXpirit> >> x = (while true; break ":s"; end); p x
<DeBot> BlaXpirit: nil - more at http://carc.in/#/r/crg
<jhass> mmh, seems like an inconsistency yeah, either it should work or it shouldn't take an argument there, I could argue both
<BlaXpirit> while true; break if while true; break true; end; end # so this does not work to break of two loops
<jhass> I'm kinda glad about that :P
<BlaXpirit> these things do work in Ruby.
<RX14> ugh, my vim seems to get slower all the time
<RX14> i wonder what causes it
<RX14> my god any attempt to make a change to the buffer absolutely kills vim
leafybasil has quit [Read error: Connection reset by peer]
leafybasil has joined #crystal-lang
<RX14> oh wow it was the syntax highlighting
<RX14> it's absolutely crawling
mrzyx has joined #crystal-lang
mrzyx has quit [Client Quit]
mrzyx has joined #crystal-lang
mrzyx has quit [Client Quit]
mrzyx has joined #crystal-lang
mrzyx has quit [Client Quit]
mrzyx has joined #crystal-lang
DeBot has quit [Quit: Crystal IRC]
DeBot has joined #crystal-lang
mrzyx has quit [Ping timeout: 250 seconds]
<RX14> hah, and the lag goes when i add in all the end statements so it compiles
<RX14> flipping crystal vim plugin
DeBot_ has joined #crystal-lang
DeBot_ has quit [Client Quit]
DeBot_ has joined #crystal-lang
DeBot_ has quit [Client Quit]
<dzv> >> a = 1; p sizeof(a)
<DeBot> dzv: Syntax error in eval:4: expecting token 'CONST', not 'a' - http://carc.in/#/r/crh
<dzv> how can i get the sizeof a variable?
mrzyx has joined #crystal-lang
mrzyx has quit [Client Quit]
sdogruyol has joined #crystal-lang
<BlaXpirit> see also: next page
<BlaXpirit> im pretty sure this is compiletime only
DeBot has quit [Quit: Crystal IRC]
DeBot has joined #crystal-lang
<dzv> seems so
<dzv> i'm ok with compile time only as long as it works on a variable
<RX14> can you return from a do-end block?
<BlaXpirit> RX14, does not appear so
<RX14> annoying
<RX14> would make my string building easier
Ven has quit [Remote host closed the connection]
<jhass> RX14: return returns from the method defining the block, break returns from the method invoking the block, next returns from the block
<RX14> oh yep i forgot
<RX14> ruby's still coming back
Ven has joined #crystal-lang
<Kilo`byte> RX14: funnily enough there actually is another segfault in there
<Kilo`byte> genererally speaking is the code very crashy
<RX14> Kilo`byte, umm, are you sure?
<RX14> i havent found any other segfaults yet
<RX14> and I'm not suing unsafes any more so I shouldnt
<Kilo`byte> check the commented out spec
<RX14> Kilo`byte, i uncommented it out
<RX14> and it works
<RX14> because I removed the code which segfauled it
<Kilo`byte> ook
<RX14> you got confused because I didn't push the segfault fix
<Kilo`byte> also i made params return an Array(String) instead of Array(String)?
<RX14> okay
<Kilo`byte> started to piss me having to put .not_nil! everywhere
<RX14> jk:w<enter> has bencome my new ctrl-s kneejerk
the_asterite has joined #crystal-lang
<Kilo`byte> also i tried your code in a benchmark: around 6 million parses peer second
<RX14> fast enoguh?
<Kilo`byte> should be :P
<RX14> i got 20 million at once
<RX14> i don't know how
<RX14> I get 10 million parsing a prefix of "nick!user@host"
<Kilo`byte> did you explicitly make sure it parses the params?
<RX14> well I used to lazilly create the command string
<RX14> but I realised that you ALWAYS want the command string
<RX14> so it just made it create the string right then
<Kilo`byte> you pretty much always want params as well
<RX14> hmmn
<RX14> true
<jhass> well, one of them
<Kilo`byte> hm?
<jhass> having a way to access a single one that's instantiated on demand might be worth it
<RX14> if I had the time I would make a fake array which parsed each parameter on demand
<Kilo`byte> sorry, reconnected and my bnc has no playback on freenode
<jhass> often I'm not interested in some params or the majority even
<Kilo`byte> well, tell me one command that doesn't need params
the_asterite has quit [Ping timeout: 246 seconds]
<Kilo`byte> can't think of any
<jhass> that's not what I mean
<RX14> yes
<RX14> i agree with jhass
<jhass> take 330 for example, the last param is completely uninteresting
<jhass> or USER where the first (iirc) is always *
<RX14> it would be nice if we didn't have to construct all the params
<RX14> what's expansive isn't the parsing, it's the memcpy that's associlated with keeping strings immutable
<jhass> just provde .param(n) ?
<Kilo`byte> first and last are interesting for USER
<jhass> anyway, it proves the point ;)
<Kilo`byte> the other two are ignored on client<->server
<Kilo`byte> on server links they are used
<RX14> i have never read the server spec lol
<Kilo`byte> one is client host and one is hop count iirc
<jhass> yes, not the point still though ;)
<Kilo`byte> yeah i get it :P
<RX14> the issue is how to implement that lazy construction with cache
<Kilo`byte> even for like 001 the last param doesn't master
<jhass> Kilo`byte: btw in case you haven't seen it yet, got a reproducer for the other issue https://github.com/manastech/crystal/issues/1275
<RX14> if you can do it, great
<Kilo`byte> *matter
<Kilo`byte> nice
<Kilo`byte> now i just gotta figure out why my code doesn't actually parse the message
<jhass> my real code is more like spawn do; loop do; spawn do; 1; end; end; sleep 1000; (well, not unlimited, just a whole bunch), no idea why it doesn't repro in the minimal example
<Kilo`byte> hmmm weird
<Kilo`byte> I'm fairly sure spawn instantly gives the fiber a time slice
<jhass> oh, no
<jhass> the fix was to Scheduler.yield after a threshold
<jhass> well, workaround
<Kilo`byte> what's diff between yield and reschedule
<jhass> yield makes sure you're queued onto the pending ones
<Kilo`byte> ic
<RX14> my god, this code is cryptic
<Kilo`byte> RX14: yours? yeah, it is
<RX14> well are the oter parsers fast?
<Kilo`byte> reasonably
<RX14> not really
<Kilo`byte> jhass: is there a sane way to update dependencies?
<Kilo`byte> other than deleting .deps.lock and .deps/
sdogruyol has quit [Read error: Connection reset by peer]
<jhass> use shards :P
<jhass> but no, having found anything
<jhass> crystal deps update isn't really doing anything
<jhass> er, haven't
<Kilo`byte> how'd i use shards :P
<Kilo`byte> never heard of them before
ssvb has quit [Ping timeout: 256 seconds]
sdogruyol has joined #crystal-lang
<RX14> well, crystal deps update worked for me?
asie has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Kilo`byte> RX14: also, the ircd slowly starts to take shape
<RX14> Kilo`byte, code?
<Kilo`byte> currently on my hdd, will shove on github now
<RX14> nice
<asterite> dzv: sizeof(typeof(a))
<Kilo`byte> TODO: fix readme
<Kilo`byte> launching is as simple as crystal run src/ircd.cr
<Kilo`byte> it launches on port 5555
Ven has joined #crystal-lang
dylanmei has joined #crystal-lang
<BlaXpirit> this blog post though http://crystal-lang.org/2015/08/24/its-a-typeof-magic.html it's SO DAMN GOOD
<jhass> :D
<vegai> it sure was!
<Kilo`byte> was?
<vegai> when I read it. It probably remains so, but I cannot be sure
<Kilo`byte> :P
<Netfeed> oh, cool, typeof(hash).new, cool feature
bcardiff has joined #crystal-lang
sdogruyol has quit [Read error: Connection reset by peer]
<crystal-gh> [crystal] technorama opened pull request #1278: Add getsockopt/setsockopt error checking and convenience methods. (master...f/socket_options) http://git.io/vs9jQ
sdogruyol has joined #crystal-lang
kyrylo has left #crystal-lang ["Konversation terminated!"]
<jhass> >> sizeof(LibC::TimeVal)
<DeBot> jhass: # => 8 - http://carc.in/#/r/crn
<jhass> >> sizeof(LibC::TimeVal|String)
<DeBot> jhass: # => 12 - http://carc.in/#/r/cro
<jhass> mmh
<RX14> >> sizeof(String)
<DeBot> RX14: # => 4 - http://carc.in/#/r/crp
<RX14> huh
sdogruyol has quit [Remote host closed the connection]
<RX14> hmmn, what's the best way to write a char to a stringbuilder
ssvb has joined #crystal-lang
<jhass> << char
<jhass> and if it isn't it should be made the best way ;P
<RX14> well as I have no faith in LLVM I will use 'x'.ord.to_u8
<RX14> because << calls to_s self
<RX14> and to_s on char calls ord.to_u8
<Kilo`byte> can you tell crystal to spit out llvm bytecode?
<RX14> yes
<Kilo`byte> possibly in text form so you can actually read it
<jhass> --emit llvm-ir iirc
<RX14> you can read it
<jhass> will dump a foo.ll
<jhass> --prelude empty might help some
<RX14> yet I have no faith that an optimisation that works one will work again
<RX14> anyway my code isn't too unreadable
<RX14> okay so my ircv3 parsing compiles
<RX14> now it only needs to work!
<Kilo`byte> xD
<jhass> hey, that's usually 3/4 there in crystal!
<jhass> if you trust llvm and stdlib that is :P
sdogruyol has joined #crystal-lang
<RX14> well shit
<RX14> all that debugging
<Kilo`byte> crystal really needs to get better at debugging :P
<RX14> and I had placed my hash[k] = v on the wrong line
<RX14> too many nested stuffs
<RX14> and i was too far in
<RX14> okay it parses simple tags!
<Kilo`byte> nice
havenwood has joined #crystal-lang
<RX14> okay now I have an infinite loop
<RX14> progress
<RX14> okay i forgot an incr
<RX14> and now it parses anything without values
<RX14> now it parses anything without eascape sequences
<RX14> even parsing a simple tag, performance goes down from nearly 4M RPS to 1.3M RPS
<RX14> just adding @tag
<RX14> or maybe it's the optimiser optimising out everything
<RX14> hmmn, no tags should mean tags are nil
<RX14> not empty hash
<RX14> Kilo`byte, if something doesn't exist it should be nil
<RX14> is there are no params, it will return nil instead of []
<RX14> this greatly helps performance
<RX14> I might want to rename params to params?
<Kilo`byte> i it makes things a lot more work though
<RX14> not really
<Kilo`byte> and i am kinda against that
<RX14> a nill check isn't bad
<Kilo`byte> well okay, i use a macro to do param checking
<Kilo`byte> so i can add that there
<Kilo`byte> but still, its somewhat unexpected
<RX14> no, we already returned nil if there was no prefix
<RX14> Kilo`byte, it helps performance by about 2 million RPS
<RX14> by over 2x
<Kilo`byte> well, again
<Kilo`byte> when do you not have params
<Kilo`byte> practically never
<RX14> but the same ius not true for prefix and tags
<RX14> and it greatly helps there
<RX14> we could make params always return []
<RX14> but then it's not consistent
<Kilo`byte> i don't really like having nilable types when its avoidable though
<Kilo`byte> my personal opinion is that the current implementation will be fast enough for just about everything you will ever want
<Kilo`byte> although, tag parsing is new
<Kilo`byte> so i haven't benchmarked that yet
<Kilo`byte> RX14: what you could do is make the tags getter lazily create an empty hash
<Kilo`byte> when its nil
<Kilo`byte> since tags are rarely read the performance should be good
tatey_ has quit []
<Kilo`byte> and then a tags? method that might return nil
<RX14> Kilo`byte, hmmn
<RX14> yeah
<RX14> tags? returns nil
<RX14> then def tags; tags? ||= []; end
<RX14> s/[]/{}/
<jhass> eh, you can't assign to a method call :P
<RX14> i meant ||
<RX14> WAIT
<RX14> I could have an immuytable {} and []
<RX14> to save performance
<RX14> maybe a Hash.empty which is immutable and there is only one instance
<Kilo`byte> oh that exists?
<Kilo`byte> that'd be handy
<RX14> it would
<RX14> but i don't think it does
<Kilo`byte> well, crystal doesn't have the concept of immutability
<Kilo`byte> sadly
Ven has quit [Remote host closed the connection]
<RX14> basically passing {} and [] should be around the same perf. as nil
<Kilo`byte> internally its a single pointer
<RX14> Kilo`byte, well you can just extend hash and block all the right methods...
<Kilo`byte> if pointer == 0 => nil, otherwise value
<Kilo`byte> thats for reference types (read: everything that is no Int, Struct, Bool, etc)
<RX14> well, whatever
<RX14> it would be great
<Kilo`byte> RX14: you should also consider using classes vs structs
bcardiff has quit [Quit: bcardiff]
blue_deref2 has joined #crystal-lang
<RX14> no, I want to use structs
<Kilo`byte> structs get copied when you pass them as param/return
<RX14> because my classes are immutable
<RX14> and structs have better passing performance
<RX14> the docs say
blue_deref2 has left #crystal-lang [#crystal-lang]
<Kilo`byte> it depends on the size of the struct
<RX14> go benchmark it
<RX14> or ask somebody likely to know
<Kilo`byte> the only performance penalty i'd see is allocating it
<RX14> like jhass
<Kilo`byte> as allocating a class uses malloc
<Kilo`byte> while allocating a struct doesn't
<dzv> can the compiler be smarter? can it auto cast small classes to structs for methods that don't modify the class?
<dzv> and then we wouldn't need to hand optimize. the optimization could also be platform specific
sdogruyol has quit [Read error: Connection reset by peer]
<jhass> dzv: I think such optimizations shouldn't be done before we finalized language design
<RX14> why not make an issue
<RX14> something like "make crystal faster"
<RX14> :P
<dzv> optimizations can be changed/removed and don't require changes to the language
<jhass> dzv: I'm more talking about effort spend now that might be nullified by language design changes
<jhass> like if we change the language in a way that makes the optimization harder or easier to implement
<jhass> while there are so many more important tasks still open :P
<dzv> isn't "struct is faster" just as likely to change if the language changes? right developers are hand optimizing based on struct. future language changes could undo that. if the optimization was automatic developers could focus on readability and IF there's a need to optimize they could
<dzv> it's more likely to break now based on structs and classes being handled differently
sdogruyol has joined #crystal-lang
<jhass> time's limited, I think it's more important it's spent on things like the multithreaded scheduler and a sane crystal deps than smarter optimizations
<jhass> it's fast enough atm
<sdogruyol> yeah crystal is already fast enough :P
<sdogruyol> cant imagine the performance with multithread though :O
<dzv> but developers are already spending time on optimization. there is a choice. a) every developer chooses to spend time on optimization because the compiler is dumb or b) a few compiler writers spend time optimizing it ONCE
<RX14> optimisations can be added after 1.0
<RX14> and 1.0 will bring a lot of people to the langauge
<dzv> jhass: i'll handle the multithreaded scheduler if someone else optimizes my classes to structs transparently
sdogruyol has quit [Remote host closed the connection]
<RX14> okay i'm segfaulting again
<RX14> wtf
<RX14> oh no i'm not what am I saying
<BlaXpirit> ok
<RX14> okay so next in a stringbuilder block doesn't break that block
<RX14> FFS
<jhass> huh
<RX14> but it does online
<BlaXpirit> :D
<RX14> not when I compile it
<RX14> on carc.in
<jhass> >> String.build {|b| b << "b"; next; b << "a" }
<DeBot> jhass: # => "b" - http://carc.in/#/r/cry
<jhass> yeah
<BlaXpirit> > cry
<jhass> maybe you have it nested somewhere or idk
<RX14> let me put it online for you to point out my mistake
<RX14> there
<RX14> is the gist
<RX14> look at line 26
<RX14> with the debug puts BN
<RX14> it has the same logic as the next is under it
<RX14> and in the output.txt it returns true
<RX14> on the debug
<RX14> yet next doesn't reak
<RX14> wait
<RX14> i'm in a for loo[
<RX14> i can just break the for loop
<RX14> what am I doing
<jhass> yeah, the next affects the while there
<jhass> not the outer block
<jhass> mmh, I wonder
<jhass> >> "cry".to_i(36)
<DeBot> jhass: # => 16558 - http://carc.in/#/r/crz
<crystal-gh> [crystal] asterite pushed 4 new commits to master: http://git.io/vsHSG
<crystal-gh> crystal/master 808a6d1 Ary Borenszweig: Fixed #1265: private macros cannot call other private macros
<crystal-gh> crystal/master 160b233 Ary Borenszweig: Fixed #1201: don't cache include generic modules and inherited generic classes parents because they might later change
<crystal-gh> crystal/master 744b447 Ary Borenszweig: Fixed #1185: disallow some types in fun pointers
<RX14> as usual, looking at my code again and I work it out myself
<RX14> okay, the parsing works
bcardiff has joined #crystal-lang
<jhass> RX14: get a rubber duck :P
<RX14> if I lived alone, yes
<RX14> everyone would think I was crazy
<jhass> huh? no, there's a WP article you can point to
Ven has joined #crystal-lang
<RX14> jhass, i know about rubber duck debugging
<RX14> but everyone would think I was crazy talking to a rubber duck
sdogruyol has joined #crystal-lang
<jhass> just add a post it with a link to that that article to it :P
<jhass> (or your head or so)
<RX14> Kilo`byte, IRCv3 parsing is on github
<Kilo`byte> kk
<RX14> so anything that can return nil ends with ?
<RX14> is my next goal
<RX14> how do I inspect the return type of a function?
<RX14> make sure it isn't a nil union
<RX14> typeof?
<jhass> yes
<jhass> >> typeof("foo".match(/bla/))
<DeBot> jhass: # => MatchData? - http://carc.in/#/r/cs0
<jhass> you can also restrict the return type
<jhass> >> def foo : String; end; foo
<DeBot> jhass: in line 4: type must be String, not Nil - http://carc.in/#/r/cs1
<sdogruyol> how can i make range.to_a to be union type e.g http://carc.in/#/r/csb
<sdogruyol> i want it to be Int32 | String
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 252 seconds]
bcardiff_ is now known as bcardiff
<RX14> well you want to init the array as Array(Int32 | String).new
<RX14> i would think
<BlaXpirit> sdogruyol, first of all u can do this http://carc.in/#/r/csg
<sdogruyol> BlaXpirit: lol
<BlaXpirit> what, sdogruyol?
<jhass> >> a = [] of Char|Int32; a.concat(1..100); a.concat('a'..'z'); a
<DeBot> jhass: # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 8 ... - http://carc.in/#/r/csj
<sdogruyol> BlaXpirit: i also expect << to work
havenwood has quit [Ping timeout: 265 seconds]
<BlaXpirit> sdogruyol, well `+` and `<<` are different
<jhass> (and `+` and `concat` are too, even though more comparable)
<sdogruyol> (1..100).to_a << ('a'..'z').to_a works in ruby
<BlaXpirit> sdogruyol, << doesn't even accept an array argument
<sdogruyol> that's why i expected it to work
<jhass> sdogruyol: yes, but it doesn't even do what you want if you actually look at the result
<jhass> >> a = [1]; a << 'a';
<DeBot> jhass: Error in line 4: no overload matches 'Array(Int32)#<<' with types Char - http://carc.in/#/r/csl
<jhass> ^ this is clear?
<sdogruyol> yeah
<jhass> >> typeof((1..2).to_a)
<DeBot> jhass: # => Array(Int32) - http://carc.in/#/r/csm
<jhass> clicked yet?
<sdogruyol> jhass: yeah i got it thanks <3
sdogruyol has quit [Read error: Connection reset by peer]
sdogruyol has joined #crystal-lang
sdogruyol has quit [Ping timeout: 255 seconds]
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 240 seconds]
bcardiff_ is now known as bcardiff
<RX14> i get about 2 million to_s sends per second
blue_deref has joined #crystal-lang
Ven has quit [Remote host closed the connection]
dylanmei has quit [Quit: ZZZzzz…]
havenwood has joined #crystal-lang
kulelu88 has joined #crystal-lang
sdogruyol has joined #crystal-lang
NeverDie has joined #crystal-lang
qard has joined #crystal-lang
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 265 seconds]
bcardiff_ is now known as bcardiff
dylanmei has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
ingsoc has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
bcardiff has quit [Ping timeout: 240 seconds]
<RX14> is there an easy way to do something on the last iteration of an eahc?
<RX14> each*
<jhass> a.each_with_index do |item, i| if i+1 == a.size
<jhass> or we can do each_with_index(1) by now I guess and save the +1
<RX14> well i can change to to be the firt iteration
<RX14> so it becomes first = true; x.each do |x, y|; unless first; p << ';'; first = false; end; end
bcardiff has joined #crystal-lang
Ven has joined #crystal-lang
dylanmei has quit [Ping timeout: 250 seconds]
<RX14> okay this is all sport of strange
<RX14> >> unless true; puts "x"; end
<DeBot> RX14: # => nil - http://carc.in/#/r/ct1
<RX14> wait WTF am I doing
<jhass> what's strange about that?
<RX14> i'm my fault yet again
<jhass> :P
<RX14> i need a rubber duck
<jhass> mmh, there's no duck emoji? :(
<RX14> aww
<RX14> okay only one failing test
<RX14> I need to escape my strings
<RX14> and I need to do it fast
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vs7Rb
<crystal-gh> crystal/master b136c29 Ary Borenszweig: Fixed #1280: escape JSON hash keys in `to_json`
Ven has quit [Remote host closed the connection]
shama has joined #crystal-lang
<travis-ci> manastech/crystal#b136c29 (master - Fixed #1280: escape JSON hash keys in `to_json`): The build has errored. https://travis-ci.org/manastech/crystal/builds/77192715
ingsoc has quit [Quit: Leaving.]
<travis-ci> manastech/crystal#b136c29 (master - Fixed #1280: escape JSON hash keys in `to_json`): The build passed. https://travis-ci.org/manastech/crystal/builds/77192715
<jhass> just restarting it won't make the issue go away...
bcardiff has quit [Quit: bcardiff]
<jhass> asterite: it often stalls in my local 32bit chroot too
bcardiff has joined #crystal-lang
shadeslayer has quit [Ping timeout: 246 seconds]
shadeslayer has joined #crystal-lang
luislavena has joined #crystal-lang
sdogruyo_ has joined #crystal-lang
sdogruyol has quit [Read error: Connection reset by peer]
havenwood has quit [Ping timeout: 246 seconds]
<RX14> Kilo`byte, is it in the ircv3 spec to escape \0?
<RX14> because really a program should never send that
<Kilo`byte> yes
<Kilo`byte> tag values can be arbitrary binary data
<RX14> i can't see it in the spec
<Kilo`byte> apparently that was changed
<Kilo`byte> i am very sure it used to support \0
<Kilo`byte> anyways since it's not in there anymore, feel free to remove it
<RX14> meh, i'll add it
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 245 seconds]
bcardiff_ is now known as bcardiff
<RX14> aparrently to_s(File.new("/dev/null")) doesn't work
<RX14> i want an IO black hole for testing my to_s implementation goddamnit
<jhass> mmh, it doesn't?
<jhass> >> "foo".to_s(File.new("/dev/null"))
<DeBot> jhass: # => 3 - http://carc.in/#/r/cta
<jhass> looks okay?
<RX14> MESSAGE = FastIrc::Message.parse "@tags;k=v :nick!user@host COMMAND args :sbabhdgaj d dgsahd sgahj daj"
<RX14> TESTIO = File.open("/dev/null")
<RX14> Benchmark.ips do |x|
<RX14> x.report("") { MESSAGE.to_s(TESTIO) }
<RX14> end
<RX14> Error writing file: Bad file descriptor (Errno)
<RX14> so i don't know what to do
<asterite> Try: File.open("/dev/null", "w")
<asterite> It's a bug, in Ruby it says "not opened for writing", that check is probably missing in crystal...
<RX14> thanks asterite
<RX14> workes now
<RX14> what's the StringPool useful for?
<asterite> It's used in the json lexer and I thought it was generic enough, but I don't know
<asterite> It lets you reuse string instances
<RX14> it could help with some docs, like most things in crystal :P
<RX14> i might get around to making docs
<RX14> for some stuff
<jhass> that's be awesome
<jhass> *that'd
<RX14> you should have written docs when you comitted it :(
<RX14> but that never happens does it :P
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 240 seconds]
bcardiff_ is now known as bcardiff
<luislavena> asterite: may I pick your brain for a few minutes?
<asterite> luislavena: sure
<luislavena> asterite: just added you to something on github, wanted to check if sounds reasonable before open-source it :D
<asterite> Let me check...
<luislavena> still need to finish docs, but readme should be good intro
<RX14> now i'm interested as to what this thing is :P
<asterite> luislavena: Looks good!
<luislavena> asterite: excellent, will add docs tonight and then open source
<luislavena> thank you.
<asterite> luislavena: Maybe Action could be a module
<luislavena> asterite: thought about that, wasn't sure how that will result in Route#action union type :P{
<benner> is it for purpose that puts [1, 2, 3] output is different than in ruby?
<asterite> Oh, I see. Yes, class for now is ok :)
<luislavena> asterite: ;-)
<asterite> benner: at least i was surprised that in Ruby that doesn't output "[1, 2, 3]"
<jhass> RX14: sounds like yet another webframework^^
<RX14> it does
<benner> asterite: we too. today found acidentally
<RX14> [speculation intensifies]
<luislavena> jhass: a slim HTTP routing toolkit, don't get too excited :P
<RX14> do we have something like rack yet?
<jhass> luislavena: have you seen artanis?
<RX14> i like artanis
<RX14> apart from the regex cost
<RX14> i was going to make a microservice in crystal, then came all this IRC stuff
<RX14> that side projects strip from commitstrip is my life basically
<luislavena> jhass: I had, thing is that building regex on every request is not fast
<luislavena> jhass: the other problem with sinatra-like approaches is test isolation
<luislavena> your block is entirely bound to the HTTP Request/Response cycle, so you end needing to run the entire stack in order to test an specific action block
<crystal-gh> [crystal] technorama opened pull request #1282: Add perm parameter to File.new & File.open (master...f/file_perm) http://git.io/vs5wi
<crystal-gh> [crystal] asterite closed pull request #1231: Process.run bugfixes and enhancements: (master...f/close_on_exec) http://git.io/vsmXc
<asterite> dzv: our wish to reduce the number of pull requests is really hard, the moment we merged one, you submitted another :-)
<asterite> (we had a good laugh)
<dzv> i got there first
<asterite> :-D
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vs56x
<crystal-gh> crystal/master 78c6f46 Technorama Ltd: Add perm parameter to File.new & File.open
<crystal-gh> crystal/master 05f3a04 Ary Borenszweig: Merge pull request #1282 from technorama/f/file_perm...
<travis-ci> manastech/crystal#d2228aa (master - Merge pull request #1231 from technorama/f/close_on_exec): The build passed. https://travis-ci.org/manastech/crystal/builds/77212656
NeverDie has joined #crystal-lang
<travis-ci> manastech/crystal#05f3a04 (master - Merge pull request #1282 from technorama/f/file_perm): The build passed. https://travis-ci.org/manastech/crystal/builds/77213810
bcardiff has quit [Quit: bcardiff]
<crystal-gh> [crystal] asterite closed pull request #1259: Add IO timeouts, nonblocking connect() and nonblocking dns (master...f/io_timeout) http://git.io/vs28I
<travis-ci> manastech/crystal#00c0424 (master - Merge pull request #1259 from technorama/f/io_timeout): The build passed. https://travis-ci.org/manastech/crystal/builds/77217675
elbow_jason has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vs5Fw
<crystal-gh> crystal/master d619bad Technorama Ltd: Implement deferred signal handling using libevent....
<crystal-gh> crystal/master ccdbf2b Ary Borenszweig: Merge pull request #1273 from technorama/f/deferred_signals...
<travis-ci> manastech/crystal#ccdbf2b (master - Merge pull request #1273 from technorama/f/deferred_signals): The build passed. https://travis-ci.org/manastech/crystal/builds/77220231
qard has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] asterite closed pull request #1278: Add getsockopt/setsockopt error checking and convenience methods. (master...f/socket_options) http://git.io/vs9jQ
<BlaXpirit> damn, i'm growing so tired of being unable to override setters of C structs
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
<travis-ci> manastech/crystal#baa13e2 (master - Merge branch 'f/socket_options' of https://github.com/technorama/crystal into technorama-f/socket_options): The build passed. https://travis-ci.org/manastech/crystal/builds/77222465
qard has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 4 new commits to master: http://git.io/vsdeK
<crystal-gh> crystal/master 4400350 Tim Hagemann: Allow for sending masked data from websocket.
<crystal-gh> crystal/master 2cca29b Tim Hagemann: Added spec for masked send in websocket.
<crystal-gh> crystal/master 7f4e994 Tim Hagemann: Use static array in mask for websocket.
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vsdvE
<crystal-gh> crystal/master eaa245f Ary Borenszweig: Small refactors in `WebSocket#send_masked`. Related to #1048
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vsdfs
<crystal-gh> crystal/master 2443f30 Benny Bach: Handle web socket close packet + add send method to web socket session class
<crystal-gh> crystal/master 1b86e9f Benny Bach: Rename web socket event handlers
<crystal-gh> crystal/master 8dc1fe9 Ary Borenszweig: Merge pull request #1264 from bebac/websocket-close...
<travis-ci> manastech/crystal#e90f903 (master - Merge pull request #1048 from kumpelblase2/patch-1): The build passed. https://travis-ci.org/manastech/crystal/builds/77223733
<RX14> Kilo`byte, updated the library on github
<Kilo`byte> kk
<RX14> added IRCv3 emitting
<travis-ci> manastech/crystal#8dc1fe9 (master - Merge pull request #1264 from bebac/websocket-close): The build passed. https://travis-ci.org/manastech/crystal/builds/77224604
<RX14> also giving this parser a \0 anywhere will basically get you shit
<RX14> also if you give it garbage it won't correct itself
<RX14> although the next message won't be garbled
<RX14> how do you get your repo to show up on crystalshards list?
<RX14> is it just anything written in crystal?
blue_deref has quit [Quit: bbn]
BlaXpirit has quit [Quit: Konversation]
knoopx has joined #crystal-lang
<jhass> yeah
<RX14> well it doesn't seem to update very fast
<RX14> so does it only get the top 100?
<jhass> apparently, I don't think that's intended though
<jhass> it was just good enough long enough
<jhass> note 100 is the maximum the github API allows per page
luislavena has quit [Remote host closed the connection]
<RX14> yeah, i'll make an issue
luislavena has joined #crystal-lang
<crystal-gh> [crystal] technorama opened pull request #1283: fork() return error checking (master...f/fork_fix) http://git.io/vsdBm
trapped has quit [Read error: Connection reset by peer]
<RX14> vim segfaulted
<RX14> woah
<jhass> time to rewrite it in crystal!
<RX14> well we already have neovim
leafybasil has quit [Remote host closed the connection]
<RX14> Kilo`byte, how do you want your name on the readme?
<RX14> Kilo`byte or Kilobyte or Kilobyte22
leafybasil has joined #crystal-lang
<RX14> Kilo`byte, get autoaway for your bouncer please
knoopx has quit [Remote host closed the connection]
shevy has joined #crystal-lang
leafybasil has quit [Ping timeout: 246 seconds]
<shevy> jhass why does the channel here have a -lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
<jhass> shevy: because #crystal was already registered and the project owners being new to freenode didn't request to take it over
<RX14> it's free now
<RX14> but I guess everyone is entrenched here
<jhass> it's empty
<jhass> != free
<shevy> jhass damn you are right... now I remember that I asked the same question already
<RX14> well, i entered it and got op
<jhass> RX14: /msg ChanServ ACCESS #crystal LIST
<shevy> it just occurred to me again because I typed /j #crystal and wondered why I was alone
<RX14> so it can't be chanserved
<jhass> sure it can
<Kilo`byte> RX14: i have
<Kilo`byte> i just don't turn off my pc when i go afk
<Kilo`byte> for like eating stuff
<jhass> GUARD just is disabled
<shevy> well looks as if I am eventually going to pick up crystal \o/
<jhass> \o/
<RX14> well I'm used to esper where the rules are different
<Kilo`byte> esper <3
<jhass> shevy: note it supports no encoding besides UTF-8 atm though
<Kilo`byte> anyways
<RX14> you could take crystal over, +f, then kick everyone...
<shevy> jhass I'll use vim!
<RX14> Kilo`byte, are you on esper?
<jhass> RX14: if you can prove affilation with an open source project of the same name, yes
<Kilo`byte> yes
<RX14> nick?
<Kilo`byte> take special chars from mine here
<RX14> we are in 2 of the same channels
<Kilo`byte> heh
<RX14> Kilo`byte, i just renamed the whole library to crystal_irc
<RX14> if I missed aything go ahead
<Kilo`byte> kk
<Kilo`byte> isn't there a library with that name already tho?
<RX14> no
<RX14> not for crystal
<RX14> oops
<RX14> derp
<RX14> i renamed to to fast_irc
<RX14> i'm tired
<RX14> also the module to FastIRC
<RX14> from FastIrc
<Kilo`byte> yeah, that looks better to me
<Kilo`byte> also my ircd currently has the work name "crystal_ircd"
<RX14> same
<RX14> i saw it
<Kilo`byte> will rename once i find a good name
<Kilo`byte> i accept suggestions
<jhass> !enable Password
<DeBot> jhass: Enabled Password.
<jhass> !password
<DeBot> overabundance sharpness exportations repudiations
<Kilo`byte> nah
<jhass> here are some random words for you
<jhass> !disable Password
<DeBot> jhass: Disabled Password.
<RX14> this performace improvement*
<Kilo`byte> actually i'd really like a profiler for crystal
<RX14> If it's a : I just calculate the langth based on the string length instead of iterating through the remaining until I get to a 0
<RX14> which obviously helps for PRIVMSG
<RX14> because they have a long section after : usually
<Kilo`byte> mhm
<Kilo`byte> or even MOTD
<Kilo`byte> because you get flooded with those
<Kilo`byte> even though only once
<RX14> i got 800000 RPS up to 1200000 RPS on a long PRIVMSG
<RX14> 1221046.55 874631.60
<Kilo`byte> although on the client you don't really need that performance unless you are doing naughty stuff (*cough*clonebot*cough*)
<RX14> umm
<RX14> but IRCD parses PRIVMSG too
<RX14> o do they?
<Kilo`byte> yeah
<RX14> well they need param 1
<RX14> not 2
<RX14> !wa
<RX14> !calc
<RX14> !help
<Kilo`byte> also, once i implement server-linking that'll open a question
<Kilo`byte> what linking protocol to use
<Kilo`byte> options: official IRC one, reuse an optimized one from another ircd, roll own
<RX14> a 1.4x improvement in parsing time with the message "nick!user@host PRIVMSG #channel :a very long, typical IRC message wooooooooocsssssssssssssssssssssssss"
<Kilo`byte> official is not the most efficient
<Kilo`byte> as it transmits "long" nicknames in plaintext, as well as even longer server names
<shevy> hmm crystal seems to create a .crystal directory in the current directory; would it be possible to specify another directory to save-to? something under /tmp/ for instance
<RX14> Kilo`byte, capnproto bindings to crystal would be nice
<Kilo`byte> i am quite familar with the inspircd one which uses UIDs
<jhass> shevy: yes, set the $CRYSTAL_CACHE_DIR environment variable
<RX14> would that make a nice protocol?
<shevy> ok
<Kilo`byte> for binary data storage i either use plain binary or msgpack
<Kilo`byte> depending on my needs
<RX14> well capnp should be fastest
<Kilo`byte> i know, but i still prefer msgpack for its compactness :P
<Kilo`byte> but i'd probably actually use an irc based one
<RX14> Kilo`byte, it's your IRCd
<Kilo`byte> not a binary one
<RX14> binary will be faster and easier to parse probably
<Kilo`byte> well, i have time to decide that
leafybasil has joined #crystal-lang
<RX14> but it's your IRCd
<Kilo`byte> yeah, thats what i am thinking too
<RX14> capnp crystal would be nice
<Kilo`byte> yup, but i am talking here to get opinions in
<Kilo`byte> :P
<shevy> CRYSTAL_CACHE_DIR works nice. I had a look there, crystal generates files such as foo.bc and foo.o - I understand that .o is an object file but what is .bc?
<RX14> llvm bytecode
<RX14> i think
<jhass> yeah
<Kilo`byte> ah right i was wondering about that the other day as well
<jhass> we can just ask file btw
<shevy> ah ok
<jhass> /home/jhass/.crystal/foo.cr/foo46cr.bc: LLVM IR bitcode
oal has quit [Ping timeout: 265 seconds]
<Kilo`byte> jhass: just wonder, is there a documentation on how names are mangled?
<jhass> doubt it
<Kilo`byte> also how does gdb/valgrind demangle names?
<jhass> still changes from time to time too
<Kilo`byte> i mean neither are crystal aware
<jhass> it doesn't?
<Kilo`byte> is it stored in the binary?
<jhass> I think it's the symbols, yeah
<Kilo`byte> the names in stack traces do not look mangled to me
<jhass> let's see if we can find the mangling code
<RX14> so you can call crystal from C?
<RX14> i guess
<RX14> i can't be bothred myself
<jhass> RX14: https://gist.github.com/k2b6s9j/3bd3aadd71db206e828f here's rust, C (or anything else really) should be similar
<jhass> fun's names are unmangled iirc
<Kilo`byte> yeah
<Kilo`byte> fun this_should_be_callable_from_c(i: Int32); i * 2; end
<Kilo`byte> ofc you can't overload funs
<Kilo`byte> kinda like you cant overload extern "C" functions in c++
<Kilo`byte> as overloading depends on name mangling
<jhass> let's hope LLVM keeps a stable debug metadata from 3.7 on and we can implement something for it
<Kilo`byte> yeah
<Kilo`byte> that'd be really cool
<jhass> it changed with 3.5, 3.6 and 3.7 :/
<Kilo`byte> i still don't understand what'd youd really change there
<Kilo`byte> like, i am assuming its some functions to add metadata
<Kilo`byte> which handle the low-level details
<jhass> iirc there are none to say things like "this function is defined here"
<jhass> but you have to use the API to create the metadata nodes
<jhass> and which ones you have to create where changed
<Kilo`byte> great
<Kilo`byte> unrelated: what happens when a Fiber gets garbage collected while its paused
<Kilo`byte> i smell a memleak there
<Kilo`byte> actually, nvm
<Kilo`byte> we have a garbage collector
<Kilo`byte> xD
<jhass> :P
<Kilo`byte> in a low level lang you may have to unwind the stack for that.
<Kilo`byte> to ensure all cleanup code is called
<Kilo`byte> (like destructors for a shared_ptr in c++)
<Kilo`byte> this might become important when you start implementing exceptions using fibers
<Kilo`byte> sorry if i keep talking about them, but i just fucking love the concept
<RX14> how good is the GC?
<RX14> in terms of performance
<shevy> ok thanks for the help, will go through the crystal tutorial in small chunks every day, hello world compiled works \o/ laters
shevy has left #crystal-lang ["I'll be back ... maybe"]
<RX14> there's a tut?
<RX14> if you mean the one in the doc that's like 10 mins tops
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vsd9W
<crystal-gh> crystal/master debcc7c Technorama Ltd: fork() return error checking
<crystal-gh> crystal/master f357ea3 Ary Borenszweig: Merge pull request #1283 from technorama/f/fork_fix...
<Kilo`byte> he probably means crystal-lang.org/docs
<RX14> well that takes about an hour
<RX14> to read
<RX14> but if you know ruby...
<RX14> well an hour to read if you know ruby
qard has quit [Quit: Textual IRC Client: www.textualapp.com]
<Kilo`byte> jhass: here is an interesting feature idk if its supported yet
<Kilo`byte> ability to include files compile time that are accessible through a variable at runtime
<Kilo`byte> or some resource api
<jhass> Kilo`byte: you're not talking about the run macro, are you?
<Kilo`byte> huh?
<RX14> no I think he means embedding the content of a binary file into the binary
<jhass> RX14: well, shevy does Ruby for like 10 years now, I could answer questions he had after 4 months
<RX14> also Kilo`byte
<jhass> Kilo`byte: ah, more like __END__ and DATA
<Kilo`byte> let myfile = include_str!("myfile.txt");
<Kilo`byte> would be rust
<jhass> you could just write a macro to do that
<jhass> foo = {{`cat myfile.txt`.stringify}}
<RX14> run macro runs a crystal program which outputs to stdout and that stdout is embedded in the crystal program
<Kilo`byte> yeah, thats what i was thinking
<Kilo`byte> that sounds hacky to me tho
<Kilo`byte> was asking if there was a better way
<Kilo`byte> i'd actually like a proper resource api tho, that'd be pretty cool
<Kilo`byte> might look into that
<RX14> you can make one with amcros
<RX14> really easily
<travis-ci> manastech/crystal#f357ea3 (master - Merge pull request #1283 from technorama/f/fork_fix): The build passed. https://travis-ci.org/manastech/crystal/builds/77243531
<RX14> also Kilo`byte look up the run macro
bcardiff has joined #crystal-lang
<RX14> Kilo`byte, releases 0.1.0 of the IRC library
<RX14> and i'm off to bed
<Kilo`byte> jhass: can i figure out at compile time if this is spec compile or regular one?
<jhass> doubt it, there isn't really anything special about it
<dzv> where does the base inspect string come from? i don't see it in object.cr
<dzv> sorry, wrong question. where is to_s defined in object? it's abstract. so where does the string come from?
<jhass> eh interesting, might be a bug that it's abstract
<jhass> it must be the macro def I linked though
<jhass> >> class Foo; def bar; 1; end; class Bar; abstract def bar; end; Bar.new.bar
<DeBot> jhass: Syntax error in eval:13: expecting identifier 'end', not 'EOF' - http://carc.in/#/r/ctm
<jhass> >> class Foo; def bar; 1; end; end; class Bar; abstract def bar; end; Bar.new.bar
<DeBot> jhass: Error in line 4: abstract def Bar#bar must be implemented by Bar - http://carc.in/#/r/ctn
<jhass> >> class Foo; macro def bar : Int32; 1; end; end; class Bar; abstract def bar; end; Bar.new.bar
<DeBot> jhass: Error in line 4: abstract def Bar#bar must be implemented by Bar - http://carc.in/#/r/cto
<jhass> mmh
<jhass> asterite: ^ can you explain?
<jhass> (not the evals, those seem correct after all)
<asterite> The question about to_s?
<jhass> yeah
<asterite> to_s or to_s(io) ?
<jhass> the latter
<asterite> to_s is defined on Object, to_s(io) is defined on every subclass of Object
<asterite> So, Int, Float, Struct, Bool, Reference...
<asterite> well, the "top-level" ones
<jhass> ah, through the macro def if not I guess?
<asterite> then user-defined types all fall under Reference or Struct
<asterite> Yes, macro def to_s
<Kilo`byte> in a spec, can i ensure that i can set up certain stuff before each test
<jhass> >> class Foo; macro def bar : Int32; 1; end; end; class Bar < Foo; abstract def bar; end; Bar.new.bar
<DeBot> jhass: # => 1 - http://carc.in/#/r/cts
<jhass> there we go, forgot to inherit
<Kilo`byte> like, in one of my tests it creates a Server, a User and a Channel with same params in pretty much every test
<asterite> Yes, abstracting a method doesn't work right now
<asterite> it probably shouldn't, because you are breaking that principle, liskov i think
<asterite> Kilo`byte: you can use a helper method that gives you those three
<Kilo`byte> hmm
<jhass> asterite: maybe we should define a let macro for spec
<Kilo`byte> yeah
<jhass> though not sure how we could cache results on the top level :/
<Kilo`byte> global variables? $__spec_name
<jhass> and then busting the caches... nvm
<Kilo`byte> does sound somewhat hacky tho
<Kilo`byte> also crystals spec system makes it really fun writing tests
kyrylo has joined #crystal-lang
<Kilo`byte> seeing all those green dots appear is really satisfying
<Kilo`byte> i always feel like i can't have enough of those
<jhass> we experimented a bit with a spec implementation that creates classes and methods for everything which would make let, before and so on all possible
<jhass> defining that many classes slowed the compiler really down though, wasn't feasible for the compiler suite at least :/
<sardaukar> hey
<Kilo`byte> expected ArgumentError with "User already exists", got #<ArgumentError: Argument error> with backtrace:
<Kilo`byte> rofl?
<sardaukar> question: is the need for a temporary var in an if needed now as a temporary thing or will it be staying past 1.0 ?
<sardaukar> for type resolution?
<Kilo`byte> sardaukar: like if stuff = @stuff
<jhass> sardaukar: it'll stay
<Kilo`byte> its a design choice
<sardaukar> what a hassle
<Kilo`byte> @stuff can be nil inside the block
<Kilo`byte> another thread might have changed it
<jhass> no, it's the only correct code
<sardaukar> I see the point, but it just feels like rote boilerplate
<sardaukar> where's my programmer happiness ? :D
<jhass> it would probably even more correct for the cases where you're not forced to it
<dzv> is that why this https://github.com/waterlink/spec2.cr wasn't imported?
<jhass> dzv: yeah
<sardaukar> let(name :: String) { "world" }
<jhass> mmh, actually no, that doesn't even do the class based approach
<sardaukar> not familiar with the :: being used like this
<jhass> sardaukar: you can actually do it for getter etc too
<sardaukar> how?
<jhass> the macro just uses it to extract the type and the name :P
<sardaukar> so :: is a macro?
<jhass> no, it's a variable declaration
<jhass> but the expression is passed to the macro
<sardaukar> ah ok
<jhass> >> class Foo; getter foo :: String; def initialize(@foo); end; end; Foo.new("foo").foo
<DeBot> jhass: # => "foo" - http://carc.in/#/r/ctx
<jhass> >> class Foo; getter foo :: String; def initialize(@foo); end; end; Foo.new(1).foo
<DeBot> jhass: # => 1 - http://carc.in/#/r/cty
<jhass> and ignores it I guess :P
<jhass> asterite: what do you think to change that to use the type as a return restriction for the method?
<jhass> in the setter macro it uses it
<jhass> >> class Foo; setter foo :: String; end; Foo.new.foo = "foo"
<DeBot> jhass: # => "foo" - http://carc.in/#/r/cu2
<jhass> >> class Foo; setter foo :: String; end; Foo.new.foo = 1
<DeBot> jhass: Error in line 4: no overload matches 'Foo#foo=' with types Int32 - http://carc.in/#/r/cu3
<sardaukar> I've found a bug in the Crystal compiler :D http://carc.in/#/r/cu5