Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
well, it's not like it would make any sense to react to it in Crystal
<jhass>
since executed compile time
unshadow has quit [Ping timeout: 256 seconds]
c355E3B has joined #crystal-lang
Ven has joined #crystal-lang
<ddfreyne>
When would it make sense to react to that in Ruby?
<strcmp1>
donno never see any code in ruby that checked the return value of require
<jhass>
yeah, makes sense was wrong I guess, it's not even possible unlike as in ruby
<strcmp1>
i think its possible but just not very useful
Ven has quit [Read error: No route to host]
DerisiveLogic has quit [Ping timeout: 258 seconds]
BlaXpirit-UA has joined #crystal-lang
BlaXpirit has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
sandelius has joined #crystal-lang
unshadow has joined #crystal-lang
<unshadow>
well it's more of a way to know if you managed to load some libs, in ruby I had a check for a project where the license file was a require, so the check would be false = exit, true = continue
<jhass>
eh, true/false indicates whether the file was loaded already or not
<jhass>
LoadError is raised if it can't be loaded
<unshadow>
Oh ... right it was a begin recue check arounf the require ...
<unshadow>
nm then ..
<unshadow>
yeha, I guess it isn't useful
<unshadow>
a question, why can't a statically compiled binery (that been built on Linux) be used on Windows ?
<unshadow>
why wont it work ?
<strcmp1>
totally different binary, linux uses ELF and idk what windows uses
<strcmp1>
s/different/incompatible/
<jhass>
also different syscalls for a lot of stuff
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
Android uses the linux kernel, so if you hit the architecture, chances are good
<unshadow>
Is there a way for me to compile a Crystal lib into .so format ? so that a Ruby FFI can be integrated around it ? (Sorry if the question is stupid)
<jhass>
I never tried, but if you use --single-module, fish the .o out of .crystal and link it manually into an .so you might have chances. You'll also need to provide an interface with fun's
<jhass>
using libruby to bind crystal functions to ruby methods might be easier
<unshadow>
Interesting, I assume that for creating a whole project one would be required to extend this lib_ruby binding quite alot.
<unshadow>
But it does looks like a nice idea
bcardiff has joined #crystal-lang
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
JBat has joined #crystal-lang
willl has joined #crystal-lang
bcardiff1 has joined #crystal-lang
<unshadow>
If I create a parser, which can parse written text, act uppon it and create an executable from it (ie. crystal code the builds code dynammicaly, and compile that code) that means I built a compiler ?
bcardiff has quit [Ping timeout: 276 seconds]
<jhass>
a special case of it, commonly referred to as transpiler
<jhass>
e.g. coffeescript is one
<epitron>
jhass: hmm... you could use the tests for the return value of 'require' as a way of conditionally compiling some codepaths
<epitron>
like, if the user has some library, then some features are enabled
<unshadow>
but if he dosn't has it, you will get a LoadError, so it's better to condition it on begin rescue then on the return value which can only return true (or false if it was alreay loaded)
<jhass>
in Ruby the idiom for that is to check whether thing I want to call is defined
<epitron>
oh, sorry, yeah :)
<epitron>
i forgot what require's return value meant
<jhass>
config.insert_middleware FooBar if const_defiend? FooBar
<epitron>
strange that OMeta isn't mentioned there anywhere
<epitron>
OMeta is a language for creating source translators
<epitron>
if you only use a subset of the transformation rules, it can be run backwards for automatic source-to-source translation from a single definition
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: http://git.io/vkUMe
<crystal-gh>
crystal/master 2ece935 Ary Borenszweig: Removed the "implicitly include generic module" rule: explicit is better than implicit and will lead to less confusion. It's also easier to implement.
<asterite>
Wow, I didn't know it tells you the error for @var2 too, I thought it only was for the receiver. Apparently I forgot about this :-P
<asterite>
I think I can check if that variable was assigned in the method's body and give a better error message
<asterite>
like what you suggest
<asterite>
could you open an issue/enhancement so I don't forget?
<jhass>
sure
<asterite>
I usually don't get those errors because I'm aware of that limitation, but for newcomers it will surely help
<jhass>
btw do you remember why you went with #crystal-lang instead of #crystal?
<jhass>
yes, that's why I bring it up, I can easily imagine it'll be the most common pitfall
<asterite>
jhass: can't remember, I think waj got it
<jhass>
#crystal is registered but unused, so if you write a mail to projects@freenode.net you'll likely get it. Would prevent from another project thinking it's a good idea to use the same name to snap it :P
<jhass>
we can then just let it forward here for example
<asterite>
Can anyone write that email?
BlaXpirit-UA has quit [Quit: Quit Konversation]
<asterite>
Mmm... what do I say, that we have this language and we'd like that channel for us?
BlaXpirit has joined #crystal-lang
<jhass>
yes, just that. And no, you need to prove affiliation with a project that uses that name
<asterite>
so you are reading @var1 before assigning to it, so the compiler treats it as nilable
<asterite>
I don't know if it really matters, why not assign to @var1 directly?
asterite has quit [Quit: Page closed]
<jhass>
oh, crystal doesn't rewrite a ||= b to a || a = b ?
<willl>
even if it does, the first part to check for falsyness might count as reading?
sandelius has joined #crystal-lang
<jhass>
yes, but that's not troublesome reading
<jhass>
for that reading it was nilable, but I'd expect the later assignment in the constructor to make it not nilable for the further cases
<jhass>
only passing out self in the constructor prior that assignment would cause that
<willl>
yeah it seems like this case would be possible to reason out that it is never actually nil
asterite has joined #crystal-lang
<asterite>
jhass: you are right, it's a ||= b ==> a || a = b
<asterite>
but still, if the compiler sees that an instance variable is used (read) before it was assigned a value, regardless of what you do with it (i.e., a nop), it will treat it as nilable
<asterite>
we could improve it, but I'm not sure it's worth it
asterite has quit [Client Quit]
<jhass>
yeah, I guess I thought checking whether the constructor has an assignment that makes it non-nilable (and none afterwards that makes it nilable) might be not too hard, but it's probably not too important either
kulelu88 has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
strcmp1 has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
<vikaton>
I'm getting a (23) Failed writing body while seting up the repo to install crystal
<jhass>
so IO is included into BufferedIO, which takes another IO-like object and wraps (not overloads!) the read and write calls
<jhass>
so BufferedIO implements IOs contract again (read/write) and delegates to the IO passed in its constructor
<jhass>
so for the IO you pass in the constructor, BufferedIO will never call <<, just read/write (and .fd, .rewind, .flush .to_fd_io apparently, sigh)
<wanderer_>
"yes, but AutoflushBufferedIO is using composition here, not inheritance" omg, yes, that's why I actually called STDOUT.to_io_fd.handle, instead of STDOUT.handle, after I noticed it doesn't inherit
<wanderer_>
thanks, that's what I just wanted to try, but why did you say it's probably not what I want?
<jhass>
huh? you said you want to subclass BufferedIO
<jhass>
look at the chain I wrote, you want to overload the FileDescriptorIO#write
<wanderer_>
ah, yeah thanks
<wanderer_>
my bad
<vikaton>
jhass, I did not have this error before tbh, happened when I updated
<jhass>
yeah, updates might change stuff
<vikaton>
well yes, but idk how2 fix at this point
<wanderer_>
btw where does the approach << uses actually come from? at first I thought it'd look like `write(obj.to_s)` instead of the `obj.to_s(self)`
<jhass>
wanderer_: it's to avoid string allocations
<wanderer_>
is it a widely used pattern or just common sense?
<jhass>
vikaton: you check whether it's nil and only do the gsub if not
<jhass>
widely used in Crystal, widely used beyond? no idea, I don't think so
<jhass>
not sure I'd call it common sense, pretty sure asterite benchmarked stuff and figured, "darn, I need to get rid of all these temporary strings"
<vikaton>
jhass, does this process involve using not_nil! ?
<jhass>
vikaton: depends on the behavior you want
<jhass>
it might as well involve Object#try or the if statement
<vikaton>
sigh :[
<vikaton>
jhass, so I shoudl encase the whole with with an if staerment and executing that if that hash is not nil?
<wanderer_>
good night everyone & danke für deine hilfe, jhass
<jhass>
there's no hash
<jhass>
wanderer_: yw
wanderer_ has quit [Quit: Page closed]
<jhass>
at least in your code there's none
<vikaton>
jhass, req.get is a hash
<jhass>
no, a ParameterHash
<vikaton>
o.0
<jhass>
I linked it
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
<vikaton>
jhass, either way, should I have an if statement that checks if req.get == Nil
<jhass>
check again, is the #[] called on nil?
<vikaton>
No
<vikaton>
sigh
<vikaton>
I'm stumped :(
<jhass>
so what is it that may return nil?
<jhass>
we ruled out .get
<vikaton>
.fetch
<jhass>
I don't see a direct call to fetch in the line that's throwing the error
<vikaton>
oh ithought u meant in general
<vikaton>
jhass: the binary key
<jhass>
well, more specifically the call to the #[] method
<vikaton>
Ok
<jhass>
on which you chain the .gsub call
<vikaton>
mhm
<jhass>
remeber, foo[bar] is just syntax sugar for foo.[](bar)
<vikaton>
ok
<vikaton>
i think im missing the big picture
bcardiff has joined #crystal-lang
bcardiff1 has joined #crystal-lang
bcardiff has quit [Read error: Connection reset by peer]
BlaXpirit has quit [Quit: Quit Konversation]
<vikaton>
ehh jhass
vikaton has quit []
vikaton has joined #crystal-lang
<vikaton>
sorry for the dc if u said anything jhass