jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
snsei has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
kulelu88 has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
snsei has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 276 seconds]
SShrike has quit [Quit: SShrike]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
Philpax has quit [Ping timeout: 252 seconds]
Oliphaunte has quit [Remote host closed the connection]
ome has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
Oliphaunte has joined #crystal-lang
snsei has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 246 seconds]
Oliphaunte has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
akwiatkowski has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
Raimondi has quit [*.net *.split]
triangles has quit [*.net *.split]
pabs has quit [*.net *.split]
txdv has quit [*.net *.split]
grindhold has quit [*.net *.split]
Yxhuvud has quit [*.net *.split]
ome has quit [*.net *.split]
BlaXpirit has quit [*.net *.split]
p0nce has quit [*.net *.split]
j2k has quit [*.net *.split]
Liothen has quit [*.net *.split]
jokke has quit [*.net *.split]
danzilio has quit [*.net *.split]
maxpowa has quit [*.net *.split]
xaxes` has quit [*.net *.split]
joshcarter has quit [*.net *.split]
tliff has quit [*.net *.split]
guilleiguaran__ has quit [*.net *.split]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
akwiatkowski has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 252 seconds]
zodiak_ has joined #crystal-lang
zodiak has quit [Ping timeout: 246 seconds]
snsei has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
soveran has joined #crystal-lang
<FromGitter> <sdogruyol> morning everyone
soveran has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
triangles has joined #crystal-lang
txdv has joined #crystal-lang
pabs has joined #crystal-lang
grindhold has joined #crystal-lang
Yxhuvud has joined #crystal-lang
BlaXpirit has joined #crystal-lang
j2k has joined #crystal-lang
p0nce has joined #crystal-lang
Liothen has joined #crystal-lang
jokke has joined #crystal-lang
xaxes` has joined #crystal-lang
maxpowa has joined #crystal-lang
joshcarter has joined #crystal-lang
danzilio has joined #crystal-lang
tliff has joined #crystal-lang
guilleiguaran__ has joined #crystal-lang
<FromGitter> <hkochev> Morning Serdar :)
<FromGitter> <alex-lairan> Hi @sdogruyol ! :)
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
<FromGitter> <sdogruyol> how are you all doing :)
soveran has quit [Remote host closed the connection]
<FromGitter> <alex-lairan> Fine and you? :)
<FromGitter> <sdogruyol> great!
<FromGitter> <alex-lairan> I have a little question :) how I can append a text to a file? I've done this https://github.com/Cruder/Opali/pull/6/files but it's destroy each time my file :/
<FromGitter> <sdogruyol> ditching up Atom editor and switching back to Sublime Text <3
<FromGitter> <sdogruyol> oh
<FromGitter> <alex-lairan> Atom is realy cool with good addons
<FromGitter> <sdogruyol> well it was cool not anymore
<FromGitter> <sdogruyol> it's consuming shit loads of resources without any purpose..
<FromGitter> <sdogruyol> @alex-lairan for you question ⏎ ⏎ ```handler = File.new("kemal.log", "a") ⏎ handler.write("some text")``` [https://gitter.im/crystal-lang/crystal?at=578217217aeb08052797f4bb]
<FromGitter> <sdogruyol> this either creates a new one if it doesnt exist or appends to existing one
<RX14> and I would store the file, not repopen it mfor every message
<FromGitter> <sdogruyol> yeah
<FromGitter> <alex-lairan> Ok thank ! :)
<FromGitter> <alex-lairan> A singleton is a good idea?
<FromGitter> <sdogruyol> exactly
<RX14> you can make it a class variable
<FromGitter> <sdogruyol> :+1:
<RX14> you don't need a singleton
<FromGitter> <alex-lairan> Ok, a static variable :)
<FromGitter> <sdogruyol> RX14 have you tried parsing a big file(something like a mkv) with your multipart implementation?
<RX14> no, but why would it not work?
<RX14> i made it streaming and constant-memory so it could handle large files
<FromGitter> <sdogruyol> just curious :)
<FromGitter> <sdogruyol> i can't wait for it get merged to std hehe
<RX14> well i've technically tested IO::Delimited with about 1GiB of data
<RX14> in a benchmark
<FromGitter> <sdogruyol> that's great
<RX14> and i just switched it to use UInt64
<RX14> so it should be able to handle >4GiB now
<FromGitter> <sdogruyol> so you treat it like a binary stream?
<RX14> yes, thats what it is
<FromGitter> <sdogruyol> cool, much more effective than handling as a string based stuff
<RX14> yes, strings can only handle UTF-8
<RX14> i would have to use a Slice anyway
<FromGitter> <sdogruyol> meanwhile do you copy anything before / after streaming?
<RX14> the stream is presented to the user, and is only valid for the duration of the block. If they want to save it or copy it thats their choice
<FromGitter> <sdogruyol> yeah
<FromGitter> <alex-lairan> ```crystal
<FromGitter> <alex-lairan> How I can edit file? It's a constant :/
<FromGitter> <alex-lairan> Oh 2s I'm stupid
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter> <alex-lairan> Edited
<BlaXpirit> yeah good job but we don't see either of your edits, just the first paste fail
<FromGitter> <alex-lairan> ```crystal
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57821a6659cfbd4c5e676205]
<FromGitter> <alex-lairan> (Context) I try to create a shards for REST API on Crystal. I've problem with File writing on crystal :)
<RX14> because FileHandler is the name of a class
<RX14> crystal distinguishes types based on name
<RX14> for a class variable you want @@file_handler
<FromGitter> <alex-lairan> Ok thank, this change my problem now :) ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57821d2f59cfbd4c5e6777e3]
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57821d3e3eaf66535e654ada]
<FromGitter> <sdogruyol> @file_handler.not_nil!.write
<FromGitter> <sdogruyol> will fix it for you
ponga has joined #crystal-lang
Philpax has joined #crystal-lang
<FromGitter> <alex-lairan> Ok thank :)
emancu has joined #crystal-lang
emancu has quit [Client Quit]
<FromGitter> <sdogruyol> RX14 is there a way to get the caller file of a macro
<RX14> use file = __FILE__ in the args
<RX14> i can get you an example
<FromGitter> <sdogruyol> which args?
crystal-lang975 has joined #crystal-lang
crystal-lang975 has quit [Client Quit]
<FromGitter> <sdogruyol> hmm
<RX14> i think it works in macros too
<FromGitter> <sdogruyol> wow, hacky but nice :P
<FromGitter> <sdogruyol> well this is needed for yield_content
<FromGitter> <sdogruyol> once a content_for is registered it's yielded even where it should be empty
<FromGitter> <sdogruyol> so i should register it with a caller
<FromGitter> <sdogruyol> and only render if the caller is correct
A124 has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
trapped has joined #crystal-lang
<RX14> hmmn
<RX14> theres probably slightly more efficiency to be gained by having a nested hashmap
<FromGitter> <sdogruyol> hmm
<FromGitter> <sdogruyol> isn't Tuple store on stack?
<RX14> yeah
<RX14> well it doesn't matter
<FromGitter> <sdogruyol> i though it'd be better to have a tuple there
<RX14> oh, yeah i meant if you had a nested hasmap (file -> id -> proc)
<RX14> you could have duplicate ids over files
<RX14> which might be useful
<FromGitter> <sdogruyol> hmm not sure why'd i need that
pawnbox has quit [Remote host closed the connection]
soveran has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
trapped has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 252 seconds]
<j2k> Compiler is saying there is no "nil" overload, but my param cant be nil
<FromGitter> <sdogruyol> then you have to tell the compiler
<FromGitter> <sdogruyol> use param.not_nil!
<j2k> perfect, thanks
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
Oliphaunte has joined #crystal-lang
<BlaXpirit> that's the crude way
<FromGitter> <sdogruyol> kinda
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Philpax has quit [Ping timeout: 252 seconds]
blassin has joined #crystal-lang
<blassin> hey!
<blassin> getting a memory invalid access error trying to create a hash table with SFML images in it
<blassin> is there a secret to it?
<blassin> or is it a case that it can't be done, because C ?
<BlaXpirit> blassin, yeah... probably that it doesn't keep references to textures
<blassin> I tried with textures and images
<blassin> same thing
<BlaXpirit> i'm rewriting crsfml but it's slow :<
<blassin> oh, so it's deprecated? :|
<BlaXpirit> blassin, just show me an example please
<BlaXpirit> blassin, i hope to rewrite crsfml but it will keep almost the same API
<BlaXpirit> it's OK as is but it does some unnecessary conversions due to the C layer, and that thing about not keeping references
<blassin> so not sure what I'm doing here, but just wanted to load images once
<BlaXpirit> blassin, it's probably about the place where you're using get_texture
snsei_ has joined #crystal-lang
<blassin> yeah, Crystal's errors are really useless :D
<blassin> but I gather as much
<blassin> actually, if I comment the line inserting the image on the hash, it works
<blassin> but OK, I'll just work around this
<BlaXpirit> blassin, you must save references to textures. probably like you're doing with images
<BlaXpirit> and actually don't need to save images if i were to guess
<blassin> how do I save the references, then?
<BlaXpirit> > like you're doing with images
<blassin> I get the error if I do it
<blassin> :/
<BlaXpirit> well I can't guess without a full reproducing example
<blassin> same error for images and textures
<blassin> ok, lemme try something then
snsei has quit [Ping timeout: 252 seconds]
<blassin> BlaXpirit: ok, so a standalone example works...
<blassin> must be something else in my code
<blassin> (I've updated the gist)
snsei_ has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<BlaXpirit> blassin, well i'm saying, it's all about the place where you're using get_texture
pawnbox_ has quit [Remote host closed the connection]
<BlaXpirit> if you apply the texture to something and forget about the texture, the texture is deleted and causes an error when something tries to use that
<blassin> I have a draw loop that right now (inefficiently, trying stuff out) loads the texture from the tilemanager, and inspects it
<blassin> on the next iteration of the draw loop, the reference is still on the TileManager class' cache, right?
<BlaXpirit> blassin, appears correct
soveran has quit [Remote host closed the connection]
<BlaXpirit> blassin, is the problem perhaps with .key?
<blassin> the only difference between the test gist and the whole code is that I have a window in the whole thing
<BlaXpirit> hm no
<blassin> and call window.clear on the draw loop
<blassin> would that cause it?
<BlaXpirit> blassin, just give me any code that crashes
<blassin> I've updated the gist - the 2nd file on it is the class that is calling TileManager now
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
snsei_ has joined #crystal-lang
<blassin> I'll try to replicate the whole thing with a window, too
<BlaXpirit> well i just wasted 5 minutes trying to make something of this code but it just does nothing
snsei has quit [Ping timeout: 276 seconds]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<blassin> BlaXpirit: sorry, will update it :|
<blassin> BlaXpirit: gist updated, now fails like my main project
<blassin> do you want the tile image I'm using too?
<BlaXpirit> no. thanks
<BlaXpirit> wut > = uninitialized SF::RenderWindow
<BlaXpirit> and then you wonder
<blassin> yeah, but I init them on start!
<blassin> (init_window)
<blassin> I just didn't want to clutter the initializer with a bunch of code
<BlaXpirit> silly
<BlaXpirit> blassin, please look at your init_artist
<BlaXpirit> you must not use uninitialized
<blassin> at all?
elomatreb has left #crystal-lang ["Leaving"]
<blassin> I only access the variables after the init_ methods
<blassin> doesn't that make a difference?
<blassin> init_artist will contain more stuff (eventually)
<BlaXpirit> blassin, yes but right now init_artist does nothing
<blassin> ok, I just moved everything into the initializer and now it works :|
blassin has quit [Quit: Page closed]
blassin has joined #crystal-lang
<blassin> sorry, got dropped :|
<blassin> as I said, I don't get it if I only use the vars after initing them
<BlaXpirit> blassin, look at your gist, @artist remains uninitialized
<blassin> ahh, right
<BlaXpirit> just shows that you definitely shouldn't do what you wanted there
<blassin> updated the gist
<blassin> I prefer this style of coding over having initializers with 20+ lines
<blassin> but I guess that's a matter of taste ;)
<blassin> thanks for all the help!
<BlaXpirit> blassin, you can base initializers on pure functions, so to say
<blassin> how so?
<BlaXpirit> @artist = make_artist instead of @artist = unitialized; init_artist
<blassin> yeah, that works too
<blassin> but now I get "Can't infer the type of instance variable @artist..."
<blassin> do I need to annotate make_artist?
snsei_ has quit [Remote host closed the connection]
<BlaXpirit> blassin, need to annotate @artist
snsei has joined #crystal-lang
<BlaXpirit> @artist : Artist = make_artist or do the annotation at the top of the class
<blassin> hmmm it seems more logical to annotate the return of the method
<blassin> but ok
<BlaXpirit> blassin, seems more logical to me as well, unfortunately it will not help and it is not planned to change
<blassin> really? that's really unfortunate
snsei_ has joined #crystal-lang
snsei_ has quit [Remote host closed the connection]
<blassin> BlaXpirit: do you know in which issue this is discussed?
<BlaXpirit> mostly IRC :|
snsei_ has joined #crystal-lang
<blassin> I think I'll open an issue, then
kulelu88 has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
<BlaXpirit> blassin, you would have to provide really strong arguments
kulelu88 has quit [Max SendQ exceeded]
<BlaXpirit> the argument against it is inconsistency - one thing works without annotation and another thing doesn't work without annotation and it seems like there is no difference between them but the difference is in the annotation of some function hidden in some library
<blassin> BlaXpirit: I can't even get it to work now lol https://gist.github.com/sardaukar/0b3331ec628d5b018c8a4aa4e5e8c38c
<BlaXpirit> what's wrong?
<blassin> this gist has the annotation, but it doesn't work either
<blassin> Can't infer the type of instance variable '@a' of A
<blassin> Can't infer the type of instance variable '@var' of A
<BlaXpirit> blassin, the code example you sent works just fine
<blassin> oops, wrong folder on the terminal :D
<blassin> so yeah, I guess opening the issue won't achieve much
<blassin> my argument for it would be to have something already present in the language for other things (method annotations) to serve for this as well
<blassin> lowers cognitive load
<blassin> one less weird thing to learn about Crystal
<blassin> fuck it, I'll open the issue anyway lol
kulelu88 has joined #crystal-lang
kulelu88 has quit [Max SendQ exceeded]
snsei has joined #crystal-lang
snsei_ has quit [Ping timeout: 258 seconds]
<blassin> if anything, I'll get closure on the reason for it!
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei_ has joined #crystal-lang
snsei_ has quit [Client Quit]
snsei_ has joined #crystal-lang
snsei_ has quit [Remote host closed the connection]
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei_ has quit [Ping timeout: 240 seconds]
Oliphaunte has quit [Remote host closed the connection]
kulelu88 has joined #crystal-lang
soveran has quit [Remote host closed the connection]
akwiatkowski has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
A124 has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
soveran has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
Oliphaunte has joined #crystal-lang
trapped has joined #crystal-lang
snsei has quit [Client Quit]
soveran has quit [Ping timeout: 272 seconds]
Raimondii is now known as Raimondi
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
trapped has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
Raimondii has joined #crystal-lang
pawnbox has quit [Ping timeout: 272 seconds]
soveran has quit [Ping timeout: 240 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
toydestroyer has quit [Remote host closed the connection]
toydestroyer has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
<jeromegn> is there a way to know (from within a macro) what’s the return type of another class’ method?
akwiatkowski has quit [Ping timeout: 244 seconds]
<jeromegn> given we know the class and method name
soveran has joined #crystal-lang
<BlaXpirit> jeromegn, appears that a return type is not as readily available. what about typeof(Another.method(blah))
<jeromegn> BlaXpirit: you mean that it could be a nice syntax for Crystal? I don’t think that method exists
<jeromegn> oh you mean actually calling the method...
pawnbox has joined #crystal-lang
<BlaXpirit> jeromegn, yes but it wouldn't actually be called
<BlaXpirit> >> typeof(p 7)
<DeBot> BlaXpirit: # => Int32 - https://carc.in/#/r/13m9
<BlaXpirit> jeromegn, note how 7 usnt printed
<jeromegn> interesting
<jeromegn> I imagine it needs the right number of args and types for each
<BlaXpirit> jeromegn, yes, needs to be a real call
pawnbox has quit [Ping timeout: 246 seconds]
<BlaXpirit> other than that, i dont think you can get the return type
<BlaXpirit> while you can get the argument types, in the Array(Def) as you linked
<jeromegn> right
blassin has quit [Quit: Page closed]
pawnbox has joined #crystal-lang
<jeromegn> ah, I’m f***ed, it’s a macro called in a class and I’m looking for the return type of an instance method
pawnbox has quit [Ping timeout: 258 seconds]
sebler has quit [Read error: Connection reset by peer]
sebler has joined #crystal-lang
<jeromegn> basically, I’m trying to upgrade hoop (https://github.com/hoopcr/hoop) to make it compatible with the latest crystal. Most of it was easy, but probably can’t work anymore: https://github.com/hoopcr/hoop/blob/master/src/foundation/nsobject.cr#L204 (it’s setting a global variable to a proc’s return value, but it can’t infer the type)
<jeromegn> I feel like hoop is trying to do too much.. mmm. I probably don’t know enough, but I felt like this could just be a normal bindings shard.
sebler_ has joined #crystal-lang
<jeromegn> reading more about Cocoa and Objective-C -> ah I see now… :(
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
sebler has quit [Ping timeout: 276 seconds]
pawnbox has quit [Ping timeout: 272 seconds]
pawnbox has joined #crystal-lang
vifino has quit [Quit: Who turned this off?! D:<]
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
vifino has joined #crystal-lang
pawnbox has joined #crystal-lang
vifino has quit [Ping timeout: 276 seconds]
pawnbox has quit [Ping timeout: 246 seconds]
vifino has joined #crystal-lang