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
waterlink has quit [Ping timeout: 245 seconds]
bcardiff has quit [Quit: Leaving.]
ismaelga has quit [Ping timeout: 250 seconds]
DerisiveLogic has quit [Ping timeout: 252 seconds]
havenwood has quit []
DerisiveLogic has joined #crystal-lang
colorados has quit [Ping timeout: 246 seconds]
colorados has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 252 seconds]
DerisiveLogic has joined #crystal-lang
<a5i> there hasnt been a commit in a while :P
havenwood has joined #crystal-lang
<a5i> >> k :: String
<DeBot> a5i: "\u{1}\u{0}\u{0}\u{0}4DǿInvalidByteSequenceError: Invalid byte sequence in UTF-8 string
<a5i> >> @k :: String
<DeBot> a5i: Error in line 3: can only declare instance variables of a non-generic class, not a main (<Program>)
<a5i> class Kam; @k :: String; end;
<a5i> >> class Kam; @k :: String; end;
<DeBot> a5i: nil
<a5i> How do I initialize a variable without setting a value?
<a5i> or at least just setting it's type
<a5i> havenwood: any difference in Crystal ?
<havenwood> a5i: yeah, some sugar like: def initialize(@x, @y)
<a5i> rly ?
<havenwood> a5i: i don't really know what you're asking, i think
<a5i> in C, to declare a variable with no value, you do 'int x;'
<a5i> in JS it's 'var x;'
harisamin has joined #crystal-lang
<a5i> but thats not exactly what my end goal is
<havenwood> a5i: you don't have to declare variables explicitly, they're just declare when you first assign the value
<a5i> I wan
<a5i> t to know if I can delcare a var with no value but declare it;s type
<a5i> like Rust has 'let x: i32;'
<a5i> can u do that in main with Crystal ?
<havenwood> a5i: variables are variable
<havenwood> a5i: i don't think there's anything along those lines
harisamin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<a5i> >> k : Int32 = 5
<DeBot> a5i: Syntax error in eval:3: unexpected token: :
<a5i> thanks
<a5i> >> 1.5,class
<DeBot> a5i: Syntax error in eval:4: expecting token 'CONST', not 'end'
<a5i> >> 1.5.class
<DeBot> a5i: Float64
bcardiff has joined #crystal-lang
ponga has joined #crystal-lang
ponga has quit [Quit: Leaving...]
ponga has joined #crystal-lang
ponga has quit [Client Quit]
bcardiff has quit [Ping timeout: 248 seconds]
ponga has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 272 seconds]
<ssvb> a5i: you can do something like "k = 5.to_i32"
<ssvb> a5i: or even use one of the integer literal suffixes - http://crystal-lang.org/docs/builtin_types/integer_types.html
bcardiff has joined #crystal-lang
_whitelogger has joined #crystal-lang
a5i has quit [Quit: Connection closed for inactivity]
Ven has joined #crystal-lang
JBat has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ponga has joined #crystal-lang
Ven has joined #crystal-lang
<BlaXpirit> >> (-7) % 5
<DeBot> BlaXpirit: -2
<BlaXpirit> >> (-7.0) % 5.0
<DeBot> BlaXpirit: Error in line 3: undefined method '%' for Float64
<BlaXpirit> sigh
<BlaXpirit> behavior is different from ruby
<BlaXpirit> both of these are supposed to be "3"
<jhass> mmh, they seem to be using the LLVM intrinsic here
a5i has joined #crystal-lang
<BlaXpirit> (-7).modulo(5)
<BlaXpirit> >> (-7).modulo(5)
<DeBot> BlaXpirit: -2
<BlaXpirit> >> (-7).remainder(5)
<DeBot> BlaXpirit: Error in line 3: undefined method 'remainder' for Int32
<BlaXpirit> if there is no way to make % behave properly without losing performance, then at least "modulo" should do it
<BlaXpirit> >> require "big_int"; (-7.to_big_i) % (5.to_big_i)
<DeBot> BlaXpirit: 3
<BlaXpirit> well that's something
<jhass> nah, we should not use the intrinsic there I'd say
<jhass> http://llvm.org/docs/LangRef.html#srem-instruction explicitly says its not modulo
<jhass> can you open an issue?
<BlaXpirit> on it
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 276 seconds]
<a5i> hmm
<a5i> >> x :: Int32; x.class
<DeBot> a5i: Int32
<BlaXpirit> i don't understand why some of Ruby's methods are missing, mainly in Array. maybe it's recently added ones?
<jhass> BlaXpirit: because nobody had time to implement them yet, contributions welcome!
<BlaXpirit> it takes me a long time to believe in myself enough to contribute code
<jhass> heh, if I could do it... ;P
<BlaXpirit> do what
<BlaXpirit> oh
<jhass> don't worry too much about forgetting an edge case, we can fix them as they're discovered
<BlaXpirit> yeah but i'm also supposed to add tests
<ponga> jhass: what happend with ruby's map.with_index replaced by single method of "map_with_index" in Array
<ponga> cos it makes more sense?
<jhass> ponga: cause we have no Enumerator yet
<ponga> ok
<a5i> we dont have alot of things
<a5i> ...yet...
<a5i> heh
<jhass> asterite's plan is to add Iterators which are tailored to the class they're used with, but I hope I could convince him to add a general Enumerator too
<jhass> BlaXpirit: writing specs is easy
<BlaXpirit> but i havent familiarized with them
<jhass> you just call your method and expect the result to be something known
<BlaXpirit> nor am i particularly interested in it for now
<jhass> it's really just some_expression.should eq some_other_expression
<jhass> for 90% of the time
<BlaXpirit> too bad it is not `==`
<BlaXpirit> gonna miss this one http://nim-lang.org/unittest.html
<jhass> there was a reason we can't do ==, but I forgot it atm
<BlaXpirit> well it's difficult to introspect then
<jhass> mh, I think it's rather that it's quite different to eq
<jhass> x = foo.should; x == value; vs. expectation = eq(value); foo.should(expectation)
<jhass> though that should still be possible
<ytti> ruby's iterators, imho, are one of the defining benefits over python
<jhass> yeah
<ytti> blocks, iterators, visibility/scoping, cleaner/purer OO
<ytti> short list
<BlaXpirit> wut
<BlaXpirit> python has much better iterators :D
<BlaXpirit> ruby doesn't seem to have any lazy computation at all
<jhass> you mean you know them much better ;)
<BlaXpirit> operations on arrays return new arrays
<jhass> no, not at all
<ponga> can you not method!
<ponga> ! at the end
<jhass> a lot of stuff returns a new Enumerator
<ytti> BlaXpirit, any enumerator can be made lazy
<jhass> and there's http://ruby-doc.org/core-2.2.2/Enumerator/Lazy.html which changes execution path
<jhass> Ruby just seems so much more stringent with the OO, Python still has so many stuff that's (or appear to be) toplevel functions
<BlaXpirit> dang it, somehow there are memory leaks in my lib T_T
<BlaXpirit> finalize isn't being called???
<jhass> >> class Foo; def finalize; puts "called!"; end; Foo.new
<DeBot> jhass: Syntax error in eval:7: expecting identifier 'end', not 'EOF'
<jhass> >> class Foo; def finalize; puts "called!"; end; end; Foo.new
<DeBot> jhass: #<Foo:0x8389FF8>
<jhass> mh, right
<BlaXpirit> yeah, simple example works
<BlaXpirit> but my finalize is not called
<jhass> well, are you sure there's no reference anymore?
<BlaXpirit> it's created locally
<BlaXpirit> i create in many different places, and not a single one is called
<jhass> note it's not called for structs, obviously
<BlaXpirit> no, it's a class
<BlaXpirit> it's pretty much just this https://bpaste.net/show/30d57e1fe92f
<BlaXpirit> I have a lot of "create"s printed, but not a single "destroy"
<jhass> well, it's the calling code that might hold some reference somewhere still
<BlaXpirit> ok, an example of calling code https://bpaste.net/show/d57c03f0feb0
<BlaXpirit> well that doesn't prove anything :| because it's being passed to draw
<jhass> yeah :)
<BlaXpirit> removed last line, same thing
<jhass> also for all I know Wrapper might hide a registry of all instances or something :P (not that I really think that)
<jhass> mh, it seems to only trigger if certain thresholds are reached
<BlaXpirit> well is raising from 30 MB to 100 enough?
<jhass> compare crystal eval 'class Foo; def finalize; puts "called"; end; end; Foo.new; nil while true' and crystal eval 'class Foo; def finalize; puts "called"; end; end; Foo.new while true'
<jhass> it stays at 100 though?
<BlaXpirit> no
<BlaXpirit> keeps growing
<BlaXpirit> i should just upload the code finally -_-
<jhass> yeah, it's hard to debug this way
ponga has quit [Remote host closed the connection]
<jhass> fully stable here
<jhass> 27668 of RES
<BlaXpirit> are you sure you're watching the right process?
<jhass> it doesn't change a byte
<BlaXpirit> jhass, maybe it's because of crystal debug build?
<BlaXpirit> no idea, but here it's definitely growing
<jhass> drcrystal is just my alias for the head compiler
<BlaXpirit> ok
<jhass> maybe different libgc version?
<BlaXpirit> maybe
<jhass> 7.4.2 here
<BlaXpirit> wait.. what's libgc?
<BlaXpirit> 7.4.2
<jhass> right, the package is just gc
<jhass> so that's not it
<jhass> there's a slight increase as the snake gets larger, but completely tolerable and I suppose its just because it has to draw more or something, raised to something like 28000 before I died ;)
wanderer_ has joined #crystal-lang
<BlaXpirit> very strange, jhass.
<BlaXpirit> here it raises until both snakes die
<jhass> it starts at ~24 and then raises to a stable value, ~27200 for a release build, I suppose that's just the GC warming up
<jhass> 24000 of course
<BlaXpirit> crystal build is release build?
<jhass> crystal build --release
<jhass> turns on LLVM optimizations
ponga has joined #crystal-lang
<BlaXpirit> what the heck.. it stabilized at 108 MB
<BlaXpirit> or wait.. it's probably cuz i lost
<BlaXpirit> no, it definitely stabilized, now at 101
<jhass> my sfml is 2.2 btw
<BlaXpirit> yes
<BlaXpirit> Private 90628 KB [heap]
<a5i> is that good
<BlaXpirit> omg, jhass, it definitely starts calling the finalizes only after it gets nearly 100MB of RAM
<BlaXpirit> i played for a good minute, and only then i got debug output that finalize is called
<jhass> what's your total free memory?
<BlaXpirit> about 10 gig
<BlaXpirit> actually 9 GiB free ram
<BlaXpirit> and 16 swap
<jhass> I only have about 3.7 free, maybe libgc inspects that?
* jhass shrugs
ponga has quit [Remote host closed the connection]
<BlaXpirit> thanks for trying this
<jhass> iirc there are some variables to tune it
<a5i> is that good memory usage from the program ?
<BlaXpirit> no
<a5i> I see
<a5i> How much memory does Nim use on this?
ponga has joined #crystal-lang
<BlaXpirit> i just filled up my RAM. still raises until 100 MB
<jhass> see my link, the logging might be interesting
<BlaXpirit> jhass, only proves what i was saying
ponga has quit [Quit: Leaving...]
<BlaXpirit> max heap settings doesnt seem to work, or i dont get it
<jhass> I see a slight steady growth (though by far not as dramatic as you, just a few kb every couple of seconds) if I enable incremental gc
<jhass> well, what the GC reports as heap is only 6000K for you
<BlaXpirit> yeah, strange
<jhass> though mine stays well below that too
<jhass> at about 370
<BlaXpirit> so like 0.3 MB for 20 MB
<BlaXpirit> and i get 6 MB for 100 MB
<BlaXpirit> realistic
<BlaXpirit> a5i, nim starts at 17 MB and stays there
<BlaXpirit> looks like crystal is supposed to stay at 27 MB but something weird is going on
<BlaXpirit> on my computer
<jhass> shall we try exchanging binaries?
<a5i> Investigation !
<BlaXpirit> good idea
<BlaXpirit> keeps growing like my binary
<jhass> looks to be a runtime phenomina from my side, same behavior
DerisiveLogic has joined #crystal-lang
<a5i> maybe asterite knows?
<a5i> whats 'class << self' in Crystal ?
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 250 seconds]
<jhass> def self.foo
<a5i> what would be in foo
<jhass> the method contents
<a5i> jhass ^
<jhass> is there a question?
<a5i> I'm not quite sure how to implement the def self.foo with this
<jhass> def self.search_page, def self.search, def self.search_play
<jhass> and so on
<a5i> o thanks
asterite has joined #crystal-lang
waj has joined #crystal-lang
waj has quit [Client Quit]
bcardiff1 has quit [Ping timeout: 256 seconds]
DerisiveLogic has quit [Ping timeout: 248 seconds]
bcardiff has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DerisiveLogic has joined #crystal-lang
shama has joined #crystal-lang
<a5i> what does "for empty hashes use '{} of KeyType => ValueType' "
<a5i> really mean?
<a5i> {} => String ?
<ytti> if you'd have hash[42] = "moi"
<ytti> it would be {} of Integer => String
<ytti> or Fixnum or whatnot
<a5i> oooo
<a5i> yeahh, this is too hard to port
BlaXpirit has quit [Read error: Connection reset by peer]
BlaXpirit has joined #crystal-lang
wanderer_ has quit [Quit: Page closed]
colorados has quit [Ping timeout: 265 seconds]
colorados has joined #crystal-lang
waj has joined #crystal-lang
strcmp1 has joined #crystal-lang
<jhass> BlaXpirit: found a gem for you https://github.com/pasberth/EndlessRuby
<BlaXpirit> > ruby
<strcmp1> jhass, almostpython would be another possible name for that one :)
<a5i> shouldnt be too hard to import them :P
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
ssvb has quit [Quit: Leaving]
<BlaXpirit> is there a way to dynamically call a function?
<BlaXpirit> function pointer? send? anything?
<jhass> BlaXpirit: you can get a pointer to a function, yes
<BlaXpirit> how
<jhass> >> ->puts(String)
<DeBot> jhass: #<(String -> Nil):0x80498B0>
<jhass> >> display = ->puts(String); display.call("hi")
<DeBot> jhass: hi
<BlaXpirit> Error: you've found a bug in the Crystal compiler. Please open an issue: https://github.com/manastech/crystal/issues
<jhass> yeah, there are still a couple of bugs around it unfortunately
<jhass> you can always wrap the call into a lambda I ugess
waterlink has joined #crystal-lang
<jhass> >> display = ->(s : String) { puts s }; display.call("hi")
<DeBot> jhass: hi
<BlaXpirit> mm that worked
<BlaXpirit> compiled*
<jhass> LLVM should optimize that away in release mode, so no real overhead except in writing it
<BlaXpirit> doesn't seem to work though
<BlaXpirit> ahhh .call
waterlink has quit [Ping timeout: 245 seconds]
harisamin has joined #crystal-lang
<asterite> So, we've been accepted to talk at http://curry-on.org/ :-). If you can participate, please do so! We'd love to meet you personally!
<jhass> nice!
<asterite> Or, if you can't participate but you can still be around, let us know too :)
<BlaXpirit> how to convert between lib enum value and integer?
<asterite> >> enum Foo; A; B; C; end; Foo::B.value
<DeBot> asterite: 1
<BlaXpirit> tried ord and to_i
<BlaXpirit> I'm talking about C enum btw
<asterite> Yes, C enum and regular enum are the same
<asterite> Some time ago enums were only in libs, but we realized they are useful outside them too
<BlaXpirit> so how to convert an integer to enum value?
<asterite> Probably to_i makes sense too
<BlaXpirit> >> enum Foo; A; B; C; end; Foo.new(2)
<DeBot> BlaXpirit: C
<BlaXpirit> ok, thanks.
<asterite> Yes, that :)
<asterite> Did you just answered yourself?
<BlaXpirit> yes
<asterite> Hahaha :)
<asterite> Note that `new` doesn't check that it's valid, but you probably get that value from C anyway so it'll be valid
<asterite> >> enum Foo; A; B; C; end; Foo.new(10)
<DeBot> asterite: 10
<asterite> BlaXpirit: crsfml is looking amazing. It's big and has lots of documentation! I also tried all the samples and they work great :)
<BlaXpirit> thx
<BlaXpirit> the worst thing right now is inability to add things to structs
<BlaXpirit> also, something weird was happening to me with GC
<BlaXpirit> we talked earlier
<asterite> Yes, I still need to answer to reply in that issue. And I read the logs about the GC, the usage growing to 100 MB
<BlaXpirit> i did spend like an hour wrapping the structs
<BlaXpirit> then i remembered about union
<BlaXpirit> and it was all crumbling apart even without it
<BlaXpirit> so i went ahead and abandoned all that
<asterite> What about the unions?
<BlaXpirit> well i'd have to wrap that too
<asterite> And I think you should. Unions are unsafe
<BlaXpirit> nope nope nope
<asterite> Ok :) . It's better if we continue discussing this in the issue about struct methods, so the conversation is not lost and others can comment too
waterlink has joined #crystal-lang
<BlaXpirit> >> enum Foo; A; B; C; end; Foo.new(2).to_s
<DeBot> BlaXpirit: "C"
harisamin has quit [Remote host closed the connection]
knoopx has joined #crystal-lang
harisamin has joined #crystal-lang
asterite has quit [Quit: Leaving.]
knoopx has quit [Remote host closed the connection]
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
waj has quit [Quit: Leaving.]
a5i has quit [Quit: Connection closed for inactivity]
DerisiveLogic has joined #crystal-lang
<BlaXpirit> scroll mouse :3
<jhass> what, no horizontal scrolling? :P
<BlaXpirit> nope :<
a5i has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
<a5i> >> ->5
<DeBot> a5i: Syntax error in eval:3: unexpected token: 5
DerisiveLogic has quit [Ping timeout: 276 seconds]
willlll has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
willlll has quit [Remote host closed the connection]