jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.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
<strcmp1> hey jhass - are you around?
<jhass> sup?
<strcmp1> i have a recurring and persistent problem related to bundling + openssl, just curious if you have seen anything like SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A before?
<strcmp1> there's a long pause, and that eventually happens. cannot figure out why, and debugging for a long time :(
<strcmp1> i also thought sslv3 was deprecated.
asterite has joined #crystal-lang
<asterite> vikaton: you there?
<vikaton> yes asterite
<asterite> thanks for posting things in reddit, and also notifying projects to update to newer crystal versions
<vikaton> No problem :P
<asterite> I'm not sure this is good, thought (honestly, I'm not sure), maybe some might think we are trying to push crystal everywhere, but that's not true
<asterite> I think I agree with the first comment, there's nothing new in 0.7.2, mostly bug fixes
<asterite> (but I just see the other reply, so that's why I'm not sure)
<jhass> strcmp1: openssl often refers to "any supported SSL/TLS version" as SSLv23
<vikaton> asterite: I didnt know Crystal was updated until I accidently saw your tweet
<vikaton> so its good as a heads up
<strcmp1> jhass, ah okay, i thought somehow forcing tlsv1_2 would fix it, and maybe rubygems.org basically didn't support it.
<asterite> Yeah, I didn't even post it in the google groups... maybe I should
<strcmp1> how can i debug such things? :)
<jhass> it's just bundler? gem install works?
<jhass> (we probably should take that to #ruby btw)
<strcmp1> alright
<kulelu88> does Crystal support HTTPS (if that makes sense) ?
asterite has quit [Ping timeout: 246 seconds]
<vikaton> kulelu88: you mean SSL? yes
<kulelu88> what big sites/apps have been built in crystal so far?
<jhass> what's big?
<kulelu88> +1 million site visits?
<jhass> none
<jhass> it's a young language, the base ecosystem is still developing
<kulelu88> can it handle that capacity? Lets say maybe 5,000 concurrent users
<vikaton> kulelu88: my website was written in crystal
<vikaton> until it broke from an update
<vikaton> and I have yet to fix it
<vikaton> vikaton: Yes ofc it can
<jhass> sure, pretty much anything can if you scale it right
<vikaton> kulelu88: Crystal is literally being added to techempoer benchmarks as we speak
<vikaton> techempower*
<kulelu88> but I'm talking about it from a cheapo perspective. I know that some big websites use very little server infrastructure because (partly) their language of choice was performant
<vikaton> Crystal is performant
<vikaton> I benchmarked myself
<kulelu88> I don't understand just 1 thing. If you don't need to tell Crystal what types the variables has, how does it compile?
<vikaton> kulelu88: Type inference
<kulelu88> at compile time?
<vikaton> Yes
<kulelu88> does this slow down the compile time?
<vikaton> Not sure, since the compile time is pretty fast as is
<jhass> the compiler is quite optimized already, so yeah, quite fast
<kulelu88> I guess we will know its true performance when someone tries to compile code with big LoC
<jhass> most time (in release mode) is spent in the llvm optimizer, by factor 50 or so, not in type interference
<jhass> like the compiler? ;)
<kulelu88> how long does the compiler take to compile itself?
<kulelu88> Also, if I am not doing type-checking in my Crystal code, is it very similar to programming in a dynamic language?
<jhass> it feels quite a bit like it, yeah
<jhass> you can go a long way with no constraints and duck typing
<jhass> Parse: 00:00:00.5395810
<kulelu88> My mind is still boggled as to why some modern static languages don't do type inference
<jhass> Type inference: 00:00:10.4589840
<jhass> Codegen (crystal): 00:00:03.8070470
<jhass> Codegen (bc+obj): 00:03:09.6533090
<jhass> Codegen (clang): 00:00:04.1050050
<jhass> compiling the compiler in release mode on my machine
<jhass> ~50kloc
<jhass> bc+obj is the llvm optimizer, mostly
<kulelu88> roughly about 4 minutes
<kulelu88> or less rather
<jhass> yeah, this is a 2010 i7
<kulelu88> not bad
<kulelu88> jhass: what do you do for a living?
<jhass> student atm
<kulelu88> aah a gifted intellectual
asterite has joined #crystal-lang
<vikaton> jhass is gifted ?!
<asterite> These are my times on a macbook pro
<asterite> Parse: 00:00:00.1063130 Type inference: 00:00:04.2346480 Codegen (crystal): 00:00:01.8285600 Codegen (bc+obj): 00:00:07.0432760 Codegen (clang): 00:00:00.9952590
<asterite> the compiler's loc is between ~30.000 loc and ~60.000
<kulelu88> germans are generally gifted, gutentag! =D
<jhass> compiler & stdlib together is at ~53kloc currently
asterite has quit [Ping timeout: 246 seconds]
<jhass> oh, my comment filter was fucked up, 49klock with 3.6kloc comments^^
<kulelu88> jhass doesn't like jokes also :-/
Codcore has joined #crystal-lang
<jhass> huh?
<jhass> Codcore: o/
<vikaton> yeah
bcardiff has joined #crystal-lang
strcmp1 has quit [Quit: Leaving]
strcmp1 has joined #crystal-lang
Cidan is now known as zz_Cidan
c355E3B has quit [Quit: Connection closed for inactivity]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
DerisiveLogic has quit [Ping timeout: 272 seconds]
<strcmp1> jhass, disabled firewalld and it works :|
<jhass> oO
<strcmp1> really shit solution...
<strcmp1> how does that even work?
<strcmp1> maybe it was just lucky, i'll keep trying
kulelu88 has left #crystal-lang ["Leaving"]
Codcore has quit [Ping timeout: 246 seconds]
zz_Cidan is now known as Cidan
<strcmp1> jhass, none the wiser, tbh but after running ssldump i know the server sends 'Alert' before the connection eventually fails.
<strcmp1> problem for tomorrow. SSL crap at 5am is no fun.
<jhass> agreed
willl has quit [Quit: Connection closed for inactivity]
Cidan is now known as zz_Cidan
Codcore has joined #crystal-lang
Codcore has quit [Ping timeout: 245 seconds]
sandelius has joined #crystal-lang
zz_Cidan is now known as Cidan
willl has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
unshadow has quit [Quit: leaving]
vikaton has quit [Quit: Connection closed for inactivity]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Cidan is now known as zz_Cidan
unshadow has joined #crystal-lang
<unshadow> How are you doing those compile benchmarks ?
<unshadow> jhass: new aur package crystal-git is failing to build
DerisiveLogic has joined #crystal-lang
<unshadow> seems like it build manually though
BlaXpirit has joined #crystal-lang
thelinuxlich has joined #crystal-lang
<thelinuxlich> is it possible to call crystal code using ffi on another language?
<unshadow> thelinuxlich: I was asking around the same question before, you have a few options, I guees you want to create some lib in Crystal and then call it from Ruby right ?
<thelinuxlich> unshadow: actually I was thinking about calling from Node
<unshadow> thelinuxlich: Ok, first, you need to use --single-module, fish the .o out of .crystal and link it manually into an .so
<unshadow> then you can just hook to it
<unshadow> You'll also need to provide an interface with fun's
<thelinuxlich> you're speaking chinese to me, I'm still building the Crystal executable :)
<thelinuxlich> I thought there were docs for this kind of stuff
<unshadow> Sadly no, this is a newish project, and the aim as of now is more to stablaize the standard libs and root out the bugs, so I belive as more developers will get in with the projcet more people will give time to document and maybe automate those sort of things
<unshadow> But really, creating the so isn't that hard, I did it a few times to play around
<thelinuxlich> ok
Ven has joined #crystal-lang
thelinuxlich has quit [Quit: Page closed]
<unshadow> jhass: here ?
willl has quit [Quit: Connection closed for inactivity]
<unshadow> Can @[Link("ssl")] be called to "/path/of/lib" ?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leafybasil has quit [Remote host closed the connection]
<strcmp1> unshadow, did you try @[Link(ldflags: '-L/path/to/lib -lssl -lcrypto')] ?
<strcmp1> btw using non-standard paths will probably break if distribute the binary around.
<unshadow> hm... thats ok, the -L option with flags seems to work, I'll just bundle the .so file in the package
leafybasil has joined #crystal-lang
JBat has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 265 seconds]
JBat has quit [Ping timeout: 276 seconds]
<unshadow> The ruby Version works, but the Crystal version complains about Libinjection::SqliScan:(.text+0x90): undefined reference to `libinjection_sqli_init'
DerisiveLogic has joined #crystal-lang
<strcmp1> what does ldd the-binary say?
<strcmp1> i guess relative paths dont work
<strcmp1> you also dont link it
<strcmp1> you just add a path
<unshadow> strcmp1: what do you mean I dont link it ?
<strcmp1> there is nothing like -linjection
<strcmp1> -L adds a path to the search path, thats all, you still have to do -linjection
vikaton has joined #crystal-lang
<unshadow> Oh.... ok I guess this makes sense, Added that and it works
<unshadow> thanks :)
<strcmp1> np
<unshadow> If I got a dtruct defenition on the C lib, (https://github.com/client9/libinjection/blob/master/src/libinjection_sqli.h#L72) Can I somehow export it to Crystal ? as in using it as a struct ?
<unshadow> dturct = struct sorry
<strcmp1> doesn't "struct" work?
<strcmp1> you will have to manually copy it to crystal
<unshadow> ok, thats what I was going to ask
<jhass> unshadow: do you need to allocate the struct yourself or access its fields?
<unshadow> jhass: passing over a pointer will work too, the thing is I want to know what size of a pointer to pass, If I can create the struct and pass a pointer of it into the program I wont need to calculate for size
<jhass> or do you have functions you can call, state* foo_new(), foo_get_string(*state) etc
<jhass> ?
c355E3B has joined #crystal-lang
<unshadow> jhass: looking at the c code example here --> https://github.com/client9/libinjection , I can see he dies this "sfilter state;" where looking at the header file sfilter is a struct, then, he passes that struct to the function like this libinjection_sqli_init(&state, input, slen, FLAG_NONE);
<unshadow> wow.. my typos are terrible sorry
<jhass> so caller side allocation indeed :/
<jhass> you might still get off with just doing sizeof(sfilter) in a small C program struct SFilter; _data : UInt8[that_value]; end
<unshadow> but, This also works if I just pass over a Pointer, so, should I just stay with passing 1024 malloc pointer ?
<unshadow> Oh.. ok
Ven has joined #crystal-lang
<jhass> well, it's essentially the same, defining a struct like that gives a bit better type safety
<jhass> so you don't start to pass a String pointer where it expects a SFilter pointer etc
<unshadow> I just call a Void pointer
<jhass> yeah, that's not so good for type safety, at least create an alias :)
<unshadow> alias Sfilter = Void* :)
<jhass> but then the size for the struct changes and you have to update all locations...
<unshadow> :(
<jhass> miss one and have subtle bugs
<unshadow> I guess I have to just create this manually
<jhass> I'd prefer the struct SFilter; _data : UInt8[size]; end; variant if you have to allocate yourself
<unshadow> Can I just do that in an emedded C kind of way ?
<jhass> let's you also do things like SFilter.new and foo :: SFilter
<jhass> mmh, a run macro that prints it could be fun :D
<jhass> but probably not worth it
<unshadow> writing in c.... I guess my day is over now hahah
Ven has quit [Read error: Connection reset by peer]
<unshadow> Then I will ne do compile it, and create an .so file, and do another lib wrapper right ?
<unshadow> ne* need
<jhass> no
<jhass> the idea is to just hardcode the value
<jhass> these don't change much usually
<unshadow> I see, so just to check it once, then put the value in the maloc
<jhass> struct SFilter; _data :: UInt8[value]; end;
<jhass> not into the malloc
<jhass> you won't need a malloc then
<unshadow> jhass: I think my lack of C expireace is making this a little hard, Let me summerize so I can see I got you. You want me to create a little C program, which will take the struct as it comes in, evaluate the size , and the I can pass it to the Pointer ? or, You do you mean I should create the Struct in Crystal ? what is this code " struct SFilter; _data :: UInt8[value]; end;" where should that go ?
<jhass> the latter, it should go into your lib declaration in crystal
<jhass> value replaced by the actual size you determined with the help of the little C program that just prints the size of the real struct
<unshadow> jhass: Ok, I get it now, thanks
<jhass> and then you replace sfilter foo in the C examples with foo :: LibInjection::SFilter
<jhass> sfilter* in the C function signatures becomes SFilter* etc
<unshadow> Should I use SFilter* and then pass pointerof( LibInjection::SFilter) ?
<jhass> yeah
<unshadow> I mean "ptr = Lib_injection::SFilter" then pass pointerof(ptr)
<unshadow> cool
<jhass> eh, no
<unshadow> Oh..
<jhass> sfilter :: LibInjection::SFilter; pointerof(sfilter)
bcardiff has joined #crystal-lang
<unshadow> what does [value] means ? in the struct ?
<unshadow> can't see it in the docs
<jhass> like Foo* is short for Pointer(Foo), Foo[n] is short for StaticArray(Foo, n) (iirc)
<jhass> UInt8 is just a type that's 1 byte long
<jhass> so we just use it to get a continues block of memory of that size
<jhass> *continuous
<unshadow> Syntax error in ./lib/libinjection.cr:5: expecting token 'CONST', not 'value'
<unshadow> _data : UInt8[value]
<unshadow> ^
<jhass> :: UInt8[123]
<jhass> or maybe it was :? I can never remember somehow
<jhass> though I think I said replace value with the actual thing like 5 times now
<unshadow> ...
<unshadow> what's the actual this ? you mean the data from user right ?
<unshadow> this* thing
<jhass> no
<jhass> the value the C program doing sizeof(sfilter) outputs
<unshadow> I really feel stupid right now
<unshadow> hhhhhhhhhhhhhhhhhh
<unshadow> haaaaaa
<unshadow> ok
<unshadow> now everything falls into place
<unshadow> Working
<unshadow> Thanks for the explanations
<vikaton> what is fork()
<jhass> fork creates a copy of the current process
<jhass> returns 0 in the copied process and the pid of the created process in the original
<jhass> see man fork
<jhass> (man 2 fork)
<unshadow> you can also use it in a block , like fork do; ... ; end
<jhass> yes, the block will be run in the copied (also called child) process only
<vikaton> what about Signal.trap() ?
<unshadow> I believe this is to catch signlas, like SIGHUP or SIGKILL and when one is traped, do something
<unshadow> like catch ^c, and write "Ctrl C presses , program closing" etc..
<jhass> SIGKILL is about the only one you can't trap ;)
<jhass> but yeah, Ctrl+C causes your process to get a SIGINT send, normal kill sends a SIGTERM
<jhass> SIGHUP is often used as "reload yourself"
<unshadow> I wasn't sure about SIGKILL ;) , I used it to handle Ctrl Z and Ctrl C , also Ctrl \
<jhass> Ctrl+\ is SIGQUIT iirc
<unshadow> vikaton: I think you can use both Signal.trap("INT") and Signal.trap("SIGINT"), at lest thats how it is in Ruby
bcardiff has quit [Quit: Leaving.]
DerisiveLogic has quit [Read error: Connection reset by peer]
<unshadow> Becuase Crystal uses '' for chars and "" for strings, and usually a string with "" will be parsed in another way to find if there are veriables inside it like #{}, dosen't that mean a loss of optimization ?
<unshadow> (This is what I know from Ruby, maybe it doesn't metter for Crystal)
DerisiveLogic has joined #crystal-lang
<strcmp1> even in ruby, "" and '' is the probably the most premature and useless optimization of all time
<strcmp1> you will surely find better places to optimize :)
<unshadow> strcmp1: really ? rubocop is kind of pressitance on that XD
<strcmp1> yeah, at least when i last looked at the benchmarks it wasn't anything that seemed significant
<jhass> rubocop is stupid about many things
<jhass> both crystal & ruby do #{} at parse time
<jhass> in ruby parse time is just harder to differentiate from runtime
<unshadow> I guess there isn't a real difference
<jhass> yes, after parse time (before the benchmark starts running), there's no difference anymore
<strcmp1> thats a real and measurable gain :)
<unshadow> wow, there are alot of mime-types
<unshadow> Gnome carshed ... brb
unshadow has quit [Quit: leaving]
<strcmp1> i am thinking of dropping gnome for similar reasons..
unshadow has joined #crystal-lang
<unshadow> btw, jhass about the former lib we talked about , should I use free or finalize ? or would the GC know about the objects ?
<unshadow> in objects I mean the Struct I created
<jhass> sfilter :: LibInjection::SFilter allocates on the stack
<jhass> so it's automatically gone the moment your method returns
bcardiff has joined #crystal-lang
Dreamer3 has quit [Quit: Leaving...]
BlaXpirit-UA has joined #crystal-lang
Dreamer3 has joined #crystal-lang
BlaXpirit has quit [Ping timeout: 252 seconds]
DerisiveLogic has quit [Read error: Connection reset by peer]
DerisiveLogic has joined #crystal-lang
ponga has joined #crystal-lang
unshadow has quit [Quit: leaving]
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
Codcore has joined #crystal-lang
unshadow has joined #crystal-lang
BlaXpirit-UA has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
<unshadow> jhass: what would you do, SQLi is true or false ?
<unshadow> maybe I should chage the def string() to def is_sqli?() then it makes more sense for true\false
<jhass> look at the source of that C function, they even use return TRUE and return FALSE
<jhass> that's just macros for 0 and 1 in C
<jhass> it's meant as boolean return value
<jhass> but +1 to renaming
<jhass> I think I'd go for contains_sqli?
havenwood has joined #crystal-lang
<unshadow> contains_sqli? it is :)
shama has joined #crystal-lang
ismaelga has joined #crystal-lang
<unshadow> Done, also updated the spec to test nil data and empty string
ismaelga has quit [Remote host closed the connection]
<jhass> unshadow: simply put a type restriction into place if you want to take strings only
<jhass> and then its a compile time error instead of a runtime one
DerisiveLogic has quit [Read error: Connection reset by peer]
<jhass> saves you the outer if too
<jhass> and the inner if/elsif/else is just return result == 1
zamith has joined #crystal-lang
<zamith> hi everyone
<jhass> hey
<zamith> how can I open a URL in crystal? Something like Ruby's open-uri
<zamith> is there something like that?
DerisiveLogic has joined #crystal-lang
<zamith> Also, is there an HTML parser for crystal?
<jhass> require "http/client"; HTTP::Client.get(url).body
<jhass> and there's a basic libxml2 binding in stdlib, that should parse html too I think
<zamith> I was thinking of writing a wrapper for https://github.com/google/gumbo-parser
<zamith> any interest in that?
<jhass> looks interesting yeah. Does it have a CSS and XPath query API?
<zamith> I would like it to
<zamith> that was the idea
<zamith> at least CSS
<zamith> a nokogiri like tool, but faster
JBat has joined #crystal-lang
jua_ has joined #crystal-lang
willl has joined #crystal-lang
<unshadow> Can it also generate XML's ?
<unshadow> jhass: How would a type restrication will look ? contains_sqli?(data : String) , is that ok ?
<jhass> yep
<unshadow> also most of the times the data could come in runtime, so lets say a users send some request , there is an issue and the request is empty, or, some issue in the code above, and then it will be nil
<unshadow> data = Socket.read_nonblock or something
<jhass> yeah, and the type restriction will force them to handle that case at compile time
<unshadow> I see, liek it wont allow for something to be nil for example... I get it
JBat has quit [Read error: Connection reset by peer]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 265 seconds]
<vikaton> Crystal is now officially in techempower
<unshadow> what's techempower ?
<vikaton> its not in round 10 tho
<vikaton> but it got officially merged to master branch
ismaelga has joined #crystal-lang
ponga has quit [Quit: Leaving...]
dom96 has quit [Changing host]
dom96 has joined #crystal-lang
<zamith> jhass: how can I add this "-I/usr/local/include -L/usr/local/lib -lgumbo" to a c binding lib?
<zamith> is @[Link("gumbo")] enough?
<BlaXpirit> zamith, it should be enough
<zamith> thanks
<BlaXpirit> include is a bit different
<jhass> I wouldn't add /usr/local/lib to the @[Link] flag but to the compiler invocation
<BlaXpirit> LD_LIBRARY_PATH="/blah/lib" crystal build --link-flags "-L/blah/lib -l/blah/include" f.cr
<jhass> --link-flags "-L/usr/local/lib", if it really isn't in your standard search path
<BlaXpirit> is something i had to use once
<BlaXpirit> but no, include really shouldn't be there
<zamith> I think junt gumbo worked
<zamith> at least on my machine
<zamith> not sure if I have to add those flags for the compiled binary to work on other machines
<zamith> btw, how do I represent const char * on a C binding? Is it UInt8*?
<jhass> yup
<jhass> and you can just pass that to String.new to turn it into a crystal string
<jhass> and String#to_unsafe returns it, so automatically converted there too
<zamith> I want to pass it in to a function
<zamith> do I have to run to_unsfae?
<zamith> *to_unsafe on it?
<jhass> you never have to call to_unsafe, crystal does it for you if it returns a matching value
<zamith> how do I do typecasting?
<jhass> as
<jhass> foo as Bar
<zamith> that's it
<zamith> I'm a bit rusty
<zamith> :P
<zamith> haven't worked with crystal in a while
ismaelga has quit [Remote host closed the connection]
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
<zamith> how can I reference an enum value defined in the c binding, from crystal?
<BlaXpirit> zamith, well it's namespaced
<BlaXpirit> Lib::EnumName::EnumValue
<jhass> LibFoo::Bar::BAZ
<zamith> cool
<zamith> thanks
Blackside921 has joined #crystal-lang
zz_Cidan is now known as Cidan
Blackside921 has left #crystal-lang [#crystal-lang]
<Codcore> Hello everybody. Has Crystal something like a send() in Ruby?
<Codcore> I mean object.send("method")
<jhass> no, again those usecases are usually covered by macros ;)
<Codcore> It doesnt work on objects and types, i tried
<jhass> it's a macro method, it works _inside_ macros
<jhass> >> macro print_methods(type); puts {{type.methods}}; end; print_methods(String)
<DeBot> jhass: in line 4: undefined macro method Path#methods' - http://carc.in/#/r/nw
<jhass> eh
<zamith> how can I represent size_t in as a type?
<jhass> >> macro print_methods(type); puts {{type.id.methods}}; end; print_methods(String)
<DeBot> jhass: in line 4: undefined macro method StringLiteral#methods' - http://carc.in/#/r/nx
<jhass> zamith: LibC::SizeT
<zamith> thanks
<zamith> and sorry for being so annoying :P
<jhass> I knew once how to resolve a Path :/
havenwood has joined #crystal-lang
<Codcore> thanks, jhass
<jhass> >> macro print_methods(type); puts {{String.methods}}; end; print_methods
<DeBot> jhass: Error in line 4: wrong number of arguments for macro 'print_methods' (0 for 1) - http://carc.in/#/r/ny
<jhass> >> macro print_methods; puts {{String.methods}}; end; print_methods
<DeBot> jhass: Error in macro 'print_methods' eval:4, line 291: undefined local variable or method 'index' - http://carc.in/#/r/nz
<jhass> meh
<jhass> >> class Class; macro def methods : Array(String); {{@type.methods.map {|method| method.name.stringify}}}; end; end; String.methods
<DeBot> jhass: # => ["bytesize", "to_i", "to_i", "to_i?", "to_i8", "to_i8", "to_i8?", "to_u8", "to_u8", "to_u8?", "to_i16", "to_i16", "to_i16?", "to_u16", "to_u16", "to_u16?", "to_i32", "to_i32", "to_i32?", "to_u32", "to_u32", "to_u32?", "to_i64", "to_i64", "to_i64?", "to_u64", "to_u64", "to_u64?", "to_u64_info", "to_f", "to_f32", "to_f64", "[]", "[]", "[]", "[]" ... - http://carc.in/#/r/o3
<jhass> that one works at least
<jhass> zamith: you aren't ;)
wanderer_ has joined #crystal-lang
<Codcore> thank you
<wanderer_> jhass: so I made a new class based on FileDescriptorIO and overwrote #write(slice : Slice(UInt8), count), now I get the puts-calls
<wanderer_> however, I don't seem to be getting the print-calls
<wanderer_> although it should call STDOUT#write as well
<jhass> sorry, too much guessing I'd need to do in that question
<wanderer_> yes, it's very vague
<wanderer_> probably because I don't have a clue what I'm doing wrong
<jhass> code usually helps to explain
<wanderer_> it's not caused by my wrapper-class
<wanderer_> to be more clear: print is not working
<wanderer_> even without any modification, while puts is
<jhass> uh
<jhass> >> print "foo"
<DeBot> jhass: foo - http://carc.in/#/r/oc
<jhass> well,...
<jhass> Codcore: sorry, you won't be able to write send with a macro, at least not for dynamic values. Think about it, macros are executed at compile time, they have no clue about what concrete value will be in your variable
<wanderer_> yesterday I pulled like 140 new commits and atm I'm integrating them into my current branch
<wanderer_> and print somehow stopped working, although puts works normally
<wanderer_> don't both simply call IO#<<?
<jhass> I doubt anybody will have a clue with that amount of information/access :/
<jhass> mmh, yeah
<wanderer_> I'm using the code from master's HEAD
<jhass> when you say puts, you're talking about puts foo vs print foo, right?
<jhass> argless puts doesn't go through IO#<<
<wanderer_> yes, the global functions that call STDOUT.print and STDOUT.puts
<wanderer_> puts "hello" vs print "hello"
<Codcore> ijhass I have concrete value(method name) at it sets at compile time and not changes
<jhass> Codcore: not even foo = "Bar"; some_macro(foo) is the same as some_macro("Bar")
<jhass> the compiler doesn't resolve the local variable at compile time
<wanderer_> fkn exceptions.. after pulling those 140 commits, I can't compile the compiler anymore because of "unexpected token: <" and because I'm unable to implement exceptions there's no unwinding thus no further information
<jhass> you need to update more often :P
<jhass> less big bangs
<jhass> fully porting to windows will be a long term effort, you need to continuously reintregrate if you want to make it
<jhass> like at very least weekly
<jhass> better daily if there was a commit upstream
<wanderer_> how annoying, now I gotta create a new copy of the old, working version, change it to print the source of the error and compile it
<wanderer_> to replace it, compile the new version again and see what's happening
<wanderer_> having exceptions would be easier, but I don't know how LLVM works
<jhass> I take it you're merge conflict free?
<wanderer_> yes
<wanderer_> can't find "<<<" or "==="
<zamith> I got a Pointer(X), how do I get X?
<jhass> git bisect might help then to narrow it to the commit that broke it for you
<jhass> zamith: .value
<zamith> thanks
<vikaton> no problem
<wanderer_> git bisect?
<jhass> yeah, you mark the working commit, the broken one and then git bisect walks you through a binary search until you identify the fist commit that introduced the issue you're testing for
<jhass> git bisect start; git bisect good 2861653a4b0ebb9dedae276e9971238d15b08280 (I guess); git bisect bad HEAD; test ? git bisect good : git bisect bad
<wanderer_> so on every iteration it changes the working copy to a previous commit?
zamith has quit [Quit: Be back later ...]
<wanderer_> do you know how I can output the current location there?
<wanderer_> I'll try @token.location
strcmp1 has quit [Ping timeout: 255 seconds]
<wanderer_> k, got the location with a newly compiled old version: unexpected token: \\crystal \\src\\compiler\\crystal\\tools\\init\\template\\example_spec.cr.ecr:5:1 <
<wanderer_> describe <%= module_name %> do
<wanderer_> I guess it's a new feature not supported yet on my older branch?
<wanderer_> nope, it's not, lol
DerisiveLogic has quit [Ping timeout: 240 seconds]
strcmp has joined #crystal-lang
strcmp is now known as strcmp1
strcmp1 has quit [Client Quit]
Codcore_ has joined #crystal-lang
strcmp1 has joined #crystal-lang
<Codcore_> why don't we use gutter instead of irc?
<Codcore_> g*gitter
<strcmp1> Codcore, gitter is for the hipsters
<strcmp1> we're keeping the scene alive, here, on IRC
<havenwood> irc \o/
<wanderer_> do I have to commit my current changes to use git bisect?
<vikaton> gitter is ually dead
<jhass> wanderer_: yes
<wanderer_> "Bisecting: 76 revisions left to test after this (roughly 6 steps)" k, let's see :)
<wanderer_> hm, it deleted my crystal.bat
<wanderer_> somehow I'm now entirely on the master-branch or something like that
<wanderer_> it doesn't recognize my stuff added for windows at all
<wanderer_> I'm too tired for this shit..
<wanderer_> wtf, like I said, I must have switched to master-branch or something, now I switched back to abort bisecting and tried to compile to see the error again and now it works...
<strcmp1> you arent as tired as me trust me, i think i might just become unconscious soon
<wanderer_> I remember when I stayed up whole nights and tried to learn but ended up playing cs:s back in school, sleep deprivation is a horrible thing
<strcmp1> it really is
<strcmp1> my problem is that i cannot sleep for longer than 4 hours without waking up, and i donno why. i might try something to put me into a deeper sleep.
<wanderer_> you could try breathing exercises, take some valerian or go see a doctor
<strcmp1> i avoid doctors like the plague :))
<strcmp1> i will check out valerian
havenwood has quit [Ping timeout: 240 seconds]
<wanderer_> actually, I had such an issue myself two years and also one year ago, two years ago I fell in love and sometimes woke up five times a night, no shit, for multiple months, then it disappeared
<wanderer_> one year ago I had it again but only for some weeks
<wanderer_> after that it was normal again
<wanderer_> or do sports ;)
<strcmp1> exercise would probably help a lot :p
<wanderer_> jhass: executing `print "lol"` results in calling IO#write(slice : Slice(UInt8))
<wanderer_> however, FileDescriptorIO#write(slice : Slice(UInt8), count) doesn't seem to get called..
<jhass> only path I find
<wanderer_> jhass: ah, now I understood
<wanderer_> print calls AutoFlushBufferedIO#write(slice : Slice(UInt8), count)
<wanderer_> but it doesn't contain a '\n' that's why flush isn't called
<jhass> ah, yeah
<wanderer_> shouldn't it always flush?
<wanderer_> also why isn't STDERR AutoFlushBufferedIO?
<jhass> I have no idea
<jhass> but that it doesn't always flush is probably the point
<wanderer_> yes, it's only copied to BufferedIO.@out_buffer
<wanderer_> but not written
<jhass> because that's slow ;)
<jhass> tty's are surprisingly slow really
<wanderer_> kezboard lazout crashed again gotta restart opera
wanderer_ has quit [Quit: Page closed]
<jhass> why do people don't use proper clients :/
wanderer_ has joined #crystal-lang
<wanderer_> >> print "hello"
<DeBot> wanderer_: hello - http://carc.in/#/r/oz
<wanderer_> why is this working, though? when is flush executed?
<jhass> well, at very last with .close I guess
<jhass> that is on program exit
<wanderer_> does it get registered with at_exit?
havenwood has joined #crystal-lang
<jhass> I don't think so, I wouldn't be surprised if the kernel triggers it
<wanderer_> but BufferedIO is using a buffer-variable that needs to get written before the program closes
<wanderer_> elsewise there is nothing to flush
<jhass> it is always written?
<jhass> oh, wait, it isn't
<jhass> I'm tired too :P
<wanderer_> AutoFlushBufferedIO only flushes if there's an \n, elsewise it calls BufferedIO#write which then flushes if the buffer is full, if not, it's used until it's full, until that nothing is written to the fd
<wanderer_> so if you use `print "hello"` and exit after that, some line must call BufferedIO#flush
<wanderer_> also, I'd expect STDOUT and STDERR to always flush if they're ttys, I really wonder why it got implemented like this
<jhass> because it's a lot faster
<jhass> syscalls are expensive, tty's are really slow
<wanderer_> I've never experienced that stdout was not flushed after writing to it (when it's a console)
<jhass> Ruby does the same actually I think, unless you set IO#sync to true
<jhass> so actually it isn't flush'ed http://carc.in/#/r/p0 :/
<jhass> the >> does a p, which triggered the flush
<wanderer_> shouldn't it be ensured that BufferedIOs flush? or at least print?
<jhass> no idea
<jhass> I didn't introduce that change
<willl> this is because of the async io, right? http://carc.in/#/r/p2
<jhass> I guess, yeah
<jhass> mh, no http://carc.in/#/r/p3 fails on 0.6 too
<jhass> maybe I didn't whitelist a syscall it needs
<willl> oh, well it also happens locally
<jhass> do you have a 0.6 to check?
<willl> I don't easily have it, but maybe if the github prebuilt ones, I can curl it on a dyno and check
<jhass> :o, segfaults locally on 0.6 too
<jhass> 0.7 gives the exception
<willl> yeah confirm, but it does get farther, actually prints some things https://gist.githubusercontent.com/will/5c9d4d6bfa17a4847918/raw/bcd739a2f527789181c23277e57747acb8a5179b/0.6
<jhass> not fore me even
<jhass> *for
<willl> Crystal 0.6.1 [48461ba] (Wed Mar 4 23:06:07 UTC 2015)
<jhass> anyway, 0.7 squashed a lot of bugs regarding closures, so maybe that's just one of them
bcardiff has joined #crystal-lang
bcardiff1 has quit [Ping timeout: 252 seconds]
Codcore_ has quit [Ping timeout: 246 seconds]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 272 seconds]
bcardiff1 has quit [Client Quit]
leafybasil has quit [Remote host closed the connection]
havenwood has quit [Ping timeout: 264 seconds]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 264 seconds]
<wanderer_> got it working now and pushed it to github, thx again jhass
<jhass> cool
leafybasil has joined #crystal-lang
<Codcore> I found a solution to call object methods based on some input. Not very nice, but works - http://carc.in/#/r/qo
bcardiff has joined #crystal-lang
jua_ has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
asterite has joined #crystal-lang
asterite has quit [Client Quit]
wanderer_ has quit [Quit: Page closed]
<jhass> cool
Codcore has quit [Ping timeout: 246 seconds]
BlaXpirit has quit [Quit: Quit Konversation]
Cocdcore has joined #crystal-lang
Cocdcore has quit [Ping timeout: 246 seconds]
DerisiveLogic has joined #crystal-lang