bcardiff has quit [Quit: Leaving.]
<naps62> Hey, anyone here? I got a couple of questions
asterite has joined #crystal-lang
<asterite> hi naps62
<naps62> I'm trying to use frank to create a very simple web app
<naps62> but every time I try to restart it, port 3000 stays busy for a while, so I can't restart it right away
<naps62> even though I don't find any processes using it
<asterite> Ah, yes, this happened to us too, but we fixed it (I can't remember how)
<asterite> Let me check... at least in Mac it doesn't happen anymore
<asterite> Mmm... are you on linux?
<naps62> Yes, Arch Linux
<naps62> So should I use a version built with github master branch?
<naps62> I'm currenly running 0.5.8, installed for AUR packages
<asterite> 0.5.8 should have that, we added that line a long time ago
<naps62> Also, I just managed to print out a bunch of assembly code. Should I just open an issue or is this already reported possibly?
<asterite> What do you mean by "print out a bunch of assembly code"?
<naps62> I was testing out some stuff involving blocks
<naps62> and the output ended up being actual assembly code
<naps62> with a warning at the end, asking me to report an issue
<asterite> Oh! It's LLVM code (but, yes, very similar to assembly). Yes, please report a bug for that
<asterite> if you can try to reduce it to the minimum code that triggers that, but if not we'll try to figure it out from some code you provide
<naps62> Yeah, I'm doing that now
<jhass> mmh, REUSEADDR should fix it for linux too
<asterite> Ok, so it seems SO_REUSEADDR has a different value in darwin and linux
<jhass> maybe wrong constant value?
<asterite> so that's why it's probably not working in linux
<asterite> (4 on mac, 2 on linux)
<asterite> jhass: is this what you are talking about?
<jhass> yeah
<asterite> Cool :)
<naps62> so I guess there's not many linux contributors here?
<asterite> I think that's true, but more true if you remove "linux" from that sentence :)
<asterite> It's a young project :)
<asterite> But maybe it's just that nobody tried to do some web-stuff yet in linux
<jhass> yeah, I'd blame lack of community instead of lack of linux ;)
<naps62> Well to be honest, this projects sounds a lot interesting to me
<asterite> (or they found that problem but didn't bother to report it or fix it)
<naps62> I only found out about it a couple of days ago though
<jhass> now tell all your friends!
<jhass> :P
<asterite> naps62: you can put this code before your code and see if it works: https://gist.github.com/asterite/69d1260c5045917ad8ab
<asterite> That is, monkeypatching TCPServer with the correct value for SO_REUSEADDR
<naps62> Yes, it seems that's working
<naps62> thanks
<naps62> about my friends, I actually found this with zamith, who is a coworker of mine
<asterite> So next version will have that fix
<naps62> He gave an internal talk on this today
<asterite> Oh! He was preparing it today, asking question here. I didn't know the talk was going to be today :)
<asterite> Was it good? :) Did he use slides?
<naps62> It was just a rehearsal
<naps62> we organize Minho.rb here in our city
<naps62> he's going to present that there, tomorrow
<naps62> He can probably share the slides here later
<asterite> muito bonito :)
<naps62> :P
<naps62> quick question
<naps62> def foo(&@block : Int -> String)
<naps62> is @block a proc that receives an Int and returns a String?
<asterite> Yes
<asterite> That should probably be Int32 -> String, maybe we need to change "Int" to something else to avoid confusions
<jhass> what's bad about using Int?
<naps62> Well, now that you mentioned that
<naps62> Switching from Int to Int32 does seem to fix the bug I was mentioning earlier
<asterite> jhass: it crashes the compiler :)
<jhass> meh
<asterite> Int would be a union of all int types
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1802 (master - abceb33 : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
<asterite> it's possible and doable, it's just not what you'd what, I think, and it would be slower than Int32
<naps62> Ok, so is that the bug I'm having?
<jhass> compile time slower, but not runtime slower, right?
<asterite> Runtime slower (see above)
<asterite> Probably just a bit slower
<asterite> The crash also probably happens if you use one of the built-in types at the top of the hierarchy: Object, Value, Reference, Struct
<asterite> We need to fix that
<asterite> Apart from that issue, the compiler is pretty solid... or at least we try to fix bugs as soon as we find them
<jhass> mmh, I have the feeling that many methods would work with accepting any kind of Int, so restricting on Int would make sense to me
<jhass> my naive idea would be to trace the calls and create copies of the method for each concrete type that's actually passed
<asterite> Yes, for restrictions that's true, but for procs it's different because you need a function pointer in memory that can accept any kind of integer
<asterite> (but methods with restrictions are instantiated when you invoke them, case by case, so that's the difference)
<asterite> Trace the .call, right?
<jhass> nah, just ignore that uninformed comment I guess :P
<asterite> But your line of though is correct
<asterite> only we tried (for a long time) to trace .call (and also trace Array#push) to avoid generic types, but it turned out to be impossible (in an efficient way)
<asterite> *thought
<naps62> Just submitted my issue here https://github.com/manastech/crystal/issues/335
<naps62> I ended up with a couple of cases that fail, and two others that end up working for completely random reasons (or so it seems from my perspective)
<naps62> And it seems the monkey patch didn't actually fix it
<naps62> I still get the same "Adress already in use" error after I use Ctrl-C to quit the server
<naps62> Probably back then it seemed to work because I just restarted the server without first making any actual requests to it
<asterite> Thanks for the bug report!
<jhass> mmh, maybe there needs to be an at exit handler that makes sure to close all connections
<naps62> in the meantime, is there any way for me to manually close it?
<naps62> Otherwise I have to wait a few seconds before starting the server again
zamith has quit [Quit: Be back later ...]
<jhass> are @@class_vars local to a class? Even when I define them in a module that's included into the class? Or are they shared among the classes the module is included in?
<jhass> I should just code up a test...
<asterite> You can try this: Signal.trap(Signal::INT) { server.close; exit }
<asterite> jhass: If you define them in a module and include them in a class, they are local to the class
<asterite> (I just tried it. I'm not sure that's the way it should work, though, but class vars are not very used in our code yet, so...)
<jhass> yeah, it's hard to overcome the instinct to not use them since Ruby made them so unusable
<asterite> Hehehe, true. And in Ruby the code I tried does a different thing than Crystal
<jhass> yes, handle @@class_vars in ruby like $globals
<jhass> forget they exist
<jhass> they're shared among the entire ancestry chain
<asterite> Could be. But sometimes it's convenient to use @@foo because it's namespaces to wherever you are using them
<asterite> but it's true that this needs more thought
<naps62> I just noticed,does crystal have method overloading?
<naps62> Also, new issue, I can't seem to use HTTP::Client
<naps62> I just get a small stack trace, and a 256 exit code
<naps62> I guess I'll open an issue for this as well
<jhass> naps62: yep, crystal has method overloading
<jhass> Could not raiseProgram terminated abnormally with error code: 1280
<jhass> do I win a prize? :P
<naps62> Nice
<naps62> The thing this lacks the most is documentation, from what I can see
<naps62> are you guys working on that, or thinking about it at least?
<jhass> it's 5 btw, crystals autorunning is not good at determining the actualy error code
<jhass> asterite: every seen Could not raise before?
<asterite> Yes
<asterite> It's either we are doing something wrong, or a bug in llvm/libunwind
<asterite> There are some docs: crystal-lang.org/docs
<asterite> For example here's overloading explained: http://crystal-lang.org/docs/syntax_and_semantics/overloading.html
<asterite> But the docs are unfinished
<jhass> any idea how to debug?
<asterite> jhass: is it a big code that triggers this?
<jhass> quite
<asterite> No, I still don't know how to debug that :(
<jhass> threading maybe? does libunwind actually handle threads?
<asterite> naps62: we are slowly working on things, but on our free time
<asterite> But we are not many right now, so... it's slow
<asterite> I don't know. The libunwind bug we have to patch to avoid this ( https://github.com/manastech/crystal/issues/327 ) seems to be related to unrooted back traces or something like that
<asterite> but that patch only affects mac, it seems... so I don't know what's wrong
<asterite> The "Could not raise" comes from here: https://github.com/manastech/crystal/blob/master/src/raise.cr#L123
<asterite> it's related to exceptions and libunwind's personality function
<asterite> but... @waj did all of that, reading docs and blog posts spread all over the internet (but I didn't) so I don't know what could be the problem
<asterite> Got to go now. But if you can reduce it to a small code, please submit a bug :-)
asterite has left #crystal-lang [#crystal-lang]
drizz_ has joined #crystal-lang
<naps62> asterite: sure, not criticizing your work obviously :)
<naps62> I hope I find the time do help a bit on my free time as well. This looks promising
drizz_ is now known as drizz
naps62 has quit [Ping timeout: 265 seconds]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
shama has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
canhtak has joined #crystal-lang
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
tmoore_ has quit [Read error: Connection reset by peer]
endou______ has quit [Ping timeout: 276 seconds]
tmoore_ has joined #crystal-lang
endou______ has joined #crystal-lang
zamith has joined #crystal-lang
leafybasil has joined #crystal-lang
zamith_ has joined #crystal-lang
zamith has quit [Ping timeout: 244 seconds]
naps62 has joined #crystal-lang
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
zamith_ is now known as zamith
asterite has joined #crystal-lang
canhtak has quit [Quit: canhtak]
asterite has quit [Quit: asterite]
canhtak has joined #crystal-lang
asterite has joined #crystal-lang
bcardiff has joined #crystal-lang
<zamith> asterite: hi
<asterite> hi zamith
<zamith> I'm trying to use frank to respond with an ecr template
<zamith> but I'm not being able to
<zamith> I get this stuff: __str__ << "\n\n \n \n \n
<asterite> What’s your code?
<asterite> (also note that frank is an experiment to try the language, we never used it seriously)
<zamith> yeah, I know. I'm more than happy to open a pr in frank if I have to
<asterite> Oh, ECR is used in another way
<asterite> Great :)
<asterite> I’ll show you an example
<zamith> ok
<zamith> I tried to use the ecr_file macro, but it doesn't work with frank
<asterite> That should work
<zamith> I'm guessing because of how frank wraps it in a block
<asterite> But to use ecr_file you use it on a view
<asterite> I’ll show you with a gist
<zamith> Syntax error in expanded macro: ecr_file:1: can't define def inside def
<zamith> this is what I get
<asterite> The idea is that you associate a view with a template, and call to_s on that viw
<asterite> view
<zamith> oh ok
<zamith> and the template gets the instance variables, or just the ones with getters?
<asterite> the template gets the instance variables too
<zamith> then that getter in the example is not neede, right?
<asterite> I just did it like that to make it more readable (maybe?)
<zamith> *needed
<asterite> Exactly
<zamith> ok
<zamith> thanks
<asterite> The ecr_file macro creates a to_s(io) method that contains the template’s code
<asterite> that’s done at compile time, so if you have a mistake in the template you will get an error (try it! for example change person.name to person.foo)
<asterite> But that’s just one way to do templates
<asterite> and we don’t have views and layouts yet (but we did some spikes and we can do it, with the same syntax as Rails, like content_for, yield, etc.)
<asterite> (but it’s kind of hacky for now)
<naps62> hi
<asterite> hi naps62
<naps62> when I do a `ecr_file "./index.ecr"`
<naps62> that's relative to the original file that was called, and not the file I'm currently in, right?
<zamith> looks nice
<naps62> It's looking like that
<asterite> I think it’s relative to the current working directory, because that’s what’s passed to the program that processes the template
<naps62> v
<asterite> you can always do “#{__DIR__}/index.ecr”
<asterite> to make it relative to a file
<zamith> Do we have a name for a crystal lib?
<zamith> like a gem for ruby
<asterite> Maybe package, or library. But we could come up with a fancier name :)
<naps62> what about shard? :P
<asterite> Could be :)
<asterite> The image of a crystal falling to the ground, exploding and throwing shards everywhere looks good on my mind :)
<naps62> Just finished porting a very small app we had to crystal
<naps62> I'll try to deploy it later today maybe
<asterite> Cool!! What does it do?
dom96 has joined #crystal-lang
<naps62> We had a small API, that, amongst other things, gives us a JSON of all pull requests we have open, accross all of our projects
<naps62> this just fetches that JSON, and shows it in a prettier view
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 244 seconds]
asterite_ is now known as asterite
asterite has quit [Quit: asterite]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 264 seconds]
asterite has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1806 (master - 9884b5f : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
shama has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff1 has quit [Ping timeout: 245 seconds]
leafybasil has quit [Remote host closed the connection]
<zamith> I like shard as well
<zamith> this is "important" to, for instance, have a file with more info about a project, say X.shardspec. Or changing Projectfile to Shardsfile.
<zamith> idk, just brainstorming here
<asterite> :)
<asterite> Projectfile will also have the source file that is the target of the compilation
<asterite> and probably other thing
<asterite> s
<zamith> hum...
<zamith> I was imagining that going into the shardspec, as Gemfile and gemspec
<asterite> Similar to how you do `cargo build`, you could do `crystal build` and it will build the project (but also, brainstorming)
<asterite> Elixir has a single file for all of that, I don’t know if there’s a need for many files
<zamith> elixir way gets kind of confusing
<zamith> especially with different envs
<zamith> btw, are you planning in having files .cr and .crs, now that you mention eleixir
<zamith> *elixir
canhtak has quit [Quit: canhtak]
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 244 seconds]
asterite_ is now known as asterite
<asterite> I don’t think there would be a clearn distinction in crystal between .cr and .crs. In elixir it says “No bytecode file will be created” as the only difference (besides the intention)
rpag has joined #crystal-lang
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 276 seconds]
<zamith> basically it would be compiled, ran and then deleted, somthing like that
<asterite> But that’s what happens when you do `crystal some_file.cr`
<zamith> yeah, right
<zamith> I was just checking if the spec were also included in the final binary
<zamith> but I guess not, right?
<zamith> *specs
<asterite> Only what your code requires (and invokes) is compiled in the final binary
<zamith> then that's cool
<zamith> :)
naps62 has quit [Remote host closed the connection]
zamith has quit [Ping timeout: 256 seconds]
<asterite> Yeah, that’s another thing I like. The binaries end up being very small (crystal itself is big because it has statically linked some libraries). And there’s no need for a dead-code elimination pass, or even to compile or check unused functions.
asterite has quit [Quit: asterite]
<rpag> is there a 'rake' for crystal yet?
naps62 has joined #crystal-lang
naps62 has quit [Ping timeout: 246 seconds]
asterite has joined #crystal-lang
<jhass> not that I noticed
<jhass> you should write one! :P
<rpag> that's why i asked =)
naps62 has joined #crystal-lang
<asterite> jhass: you started writing one and ran into some issues, I can’t remember which ones
<jhass> yeah...
<jhass> the prelude thing I guess?
<jhass> also no run_file macro, but that I worked around by shelling out
<asterite> Yes, but I think that should be fixed by now because of the require
<asterite> (the prelude thing)
<jhass> yeah, maybe I should resurect that branch sometime
<jhass> but if rpag takes that over now...
<jhass> :P
<asterite> :)
<asterite> rpag: did you do pry?
naps62 has quit [Read error: Connection reset by peer]
naps62 has joined #crystal-lang
<naps62> Hey there
<naps62> I was trying to add a "local" method to the Projectfile DSL, to fetch dependencies in your file system
<naps62> is this an interesting feature, or is it intentionally left out for some reason?
<asterite> I think it’s interesting, so you can develop two libraries at the same time or have a copy of one and do patches to it before having to push it to use it (similar to Gemfile’s path)
<asterite> It’s left out only because we didn’t have time to do it yet
<asterite> so it would be awesome to have it :)
<asterite> (there’s also bundler’s local path thingy we could do, but that’s a change in the compiler, I guess)
<naps62> One issue though
<naps62> I'm having trouble compiling the compiler
<naps62> I added a Makefile.local with "threads := 2"
<naps62> but I see a lof of crystal processes anyway, and my laptop eventually hangs
<asterite> Hmm… strange
<asterite> If you run all specs it works?
<asterite> (in any case, you don’t need to compile the compiler to add that feature you want)
<naps62> Yes, but it's the only way for me to manually test it right?
<naps62> well, "make spec" gives me a "forl: cannot allocate memory"
<naps62> *fork: cannot allocate memory
<naps62> it seems to be spawning a lot of processes
<asterite> You can do `crystal src/crystal/project_cli.cr` to try the Projectfile
<asterite> What happens if you use one thread?
rpag has quit [Quit: Leaving]
<naps62> same thing, it just keeps spawning processes
<naps62> looking at the size of the list, I'm guessing it just spawns them forever, until it runs out of memory
<naps62> perhaps a linux issue like the one with the constant yesterday?
<asterite> If you do `bin/crystal build src/compiler/crystal.cr` the same happens?
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 255 seconds]
asterite_ is now known as asterite
bcardiff has quit [Quit: Leaving.]
<naps62> I just reinstalled crystal (using the one from AUR) and now it works
<naps62> even though this is suposedly using the local crystal binary, and not the system one
naps62 has quit [Ping timeout: 246 seconds]
asterite has quit [Quit: asterite]
asterite has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
asterite has quit [Quit: asterite]
asterite has joined #crystal-lang
asterite has quit [Client Quit]
asterite has joined #crystal-lang
naps62 has joined #crystal-lang
rpag has joined #crystal-lang
bcardiff has joined #crystal-lang
leafybasil has joined #crystal-lang
asterite has quit [Quit: asterite]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Read error: Connection reset by peer]
leafybasil has quit [Remote host closed the connection]
rpag has quit [Quit: Leaving]
r20 has joined #crystal-lang
seb_ has joined #crystal-lang
<seb_> Hey, it doesn’t appear that crystal support a “=“ method. e.g. class Hello
<seb_> sorry
zamith has joined #crystal-lang
<seb_> for example a method like this: def =(some_value)
<seb_> do we think it will support a method called “=“ in he future?
<jhass> ruby does neither, what would it do?
<jhass> I mean that totally conflicts with local variable assignment, wouldn't it?
<seb_> yeah you’re right
<seb_> but I guess it supports a method called “==“ for example
<jhass> yes
<seb_> sweet
<seb_> thanks
<zamith> Here's the presentation I gave at a local ruby group today, if anyone's interested: https://speakerdeck.com/zamith/crystal-clean
<seb_> sweet I’ll have a look
bcardiff1 has quit [Quit: Leaving.]
<naps62> What's the current convention (if any) for building libraries? (I'll just start calling them shards I guess)
<jhass> I think we (as a community) are still shaping that ;)
<naps62> When i require "frank", for instance. Is it expecting a "lib/frank/frank.cr" to exist?
<naps62> Ok so let me rephrase that. What is it looking for in the current implementation? :P
<jhass> first of all libs relative to the current working directory (while compiling) is by default in CRYSTAL_PATH (the load path)
<jhass> the "libs" directory that is
<jhass> I didn't look yet in how exactly crystal deps pulls repos into that dir
<jhass> the main stuff for what require is doing is in https://github.com/manastech/crystal/blob/master/src/compiler/crystal/crystal_path.cr iirc