ismaelga has quit [Remote host closed the connection]
<crystal-gh>
[crystal] asterite pushed 3 new commits to master: http://git.io/vJID9
<crystal-gh>
crystal/master c2aedda Ary Borenszweig: Optimized STDIN.gets because it's so common some benchmarks and mini programs will be slow if not using BufferedIO
<crystal-gh>
crystal/master 280a505 Ary Borenszweig: Fixed: lib fun weren't propagating raise info
<crystal-gh>
crystal/master c142140 Ary Borenszweig: Revert "Assume all C functions are marked with @[Raises], in case they invoke functions defined in Crystal"...
<Dreamer3>
is there anything like "browser" but post macros?
<Dreamer3>
so i can learn what the macros are doing
ismaelga has joined #crystal-lang
<Dreamer3>
can i set a variable in one macro and use it in another?
<Dreamer3>
ok any simple ORMs yet? :)
<Dreamer3>
ok macros look kind of powerful
<Dreamer3>
can i make a macro that encloses things?
<Dreamer3>
like to pre/postfix methods
<fowl>
wanderer_, hey i am just getting back from dinner, will try it shortly
ponga has joined #crystal-lang
<Dreamer3>
can i get an example of a macro that's aware of context again?
<Dreamer3>
>> 1+1
<DeBot>
Dreamer3: 2
<Dreamer3>
>> macro x; puts {{x.id}}; end; x
<DeBot>
Dreamer3: in line 3: undefined macro variable 'x'
ismaelga has quit [Remote host closed the connection]
<zipR4ND>
hey crystal people, is there any explanation on how to use threads ?
<jhass>
not much to it, thread = Thread.new { concurrent_code }; thread.join
<BlaXpirit>
how to make empty array of arrays of type?
<jhass>
Array(Array(X))
<BlaXpirit>
oh
<jhass>
>> [] of Array(String]
<DeBot>
jhass: Syntax error in eval:3: expecting token ')', not ']'
<jhass>
>> x = [] of Array(String]; x << ["foo"]
<DeBot>
jhass: Syntax error in eval:3: expecting token ')', not ']'
<jhass>
bah, you get it
waterlink has joined #crystal-lang
<BlaXpirit>
dang, but i still need a block because i'm actually creating array of empty arrays of arrays of type
<BlaXpirit>
thanks
<BlaXpirit>
what i mean is Array.new(count, [] of Array(SF::Color?)) is an array of the same []
<asterite>
you can use a block
<zipR4ND>
sorry, im new to threading (no c experience ..) what does thread join do? basically i want to dispatch an action to another part of of my code, which eventually returns a result, but continue to execute code after the result has returned to the first thread ...
<asterite>
>> Array.new(3) { [] of String }.map &.object_id
<BlaXpirit>
[:24:37] <BlaXpirit> but i still need a block
<BlaXpirit>
thanks
<zipR4ND>
particulary: what does thread.join do ?
<asterite>
it waits for the thread to finish
<asterite>
that is, it blocks until the thread finishes executing
<zipR4ND>
ok
ponga has quit [Quit: Leaving...]
<zipR4ND>
what i want is an application wide event hub that executes independently of other parts of the application, which listen to it and may block until certain events occur ...
willlll has quit [Quit: willlll]
ponga has joined #crystal-lang
ponga has quit [Client Quit]
<travis-ci>
manastech/crystal#2272 (master - 7f20fdc : Ary Borenszweig): The build is still failing.
<asterite>
zipR4ND: in the next release I think that will be easier to accomplish
willlll has joined #crystal-lang
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vJOD4
<crystal-gh>
crystal/master 5128361 Ary Borenszweig: libevent: link to rt on linux
BlaXpirit_ has joined #crystal-lang
BlaXpirit has quit [Ping timeout: 276 seconds]
BlaXpirit-UA has joined #crystal-lang
BlaXpirit_ has quit [Ping timeout: 276 seconds]
BlaXpirit has joined #crystal-lang
BlaXpirit-UA has quit [Ping timeout: 272 seconds]
<zipR4ND>
asterite: im build from git, can i already benefit? :)
<asterite>
Sure. You can use spawn and a channel to communicate between the processes
<asterite>
if you know how Go works, it's similar here
<ssvb>
asterite: does it really use multiple threads?
<asterite>
Not yet, just one thread for now
<zipR4ND>
i'll look into that ..
<asterite>
Note that this is all very experimental
BlaXpirit has quit [Ping timeout: 256 seconds]
<ssvb>
ok, I had a look at the fiber/spawn/channel implementation examples and it was more like a cooperative multithreading
<ssvb>
zipR4ND: you can always start multiple threads, exchange data between them via some data structure (array or whatever) and protect access to this shared data structure using a mutex
<asterite>
but I don't want to delay the next release forever
<asterite>
there are many bug fixes and improvements since 0.6.1, I feel that version is kind of useless now
<vikaton>
^
<vikaton>
I concur
<vikaton>
are you posting a blog post ?
<asterite>
DeBot and prax.cr will probably break
<jhass>
yeah, and I don't really have time to do crystal-posix-io atm
<asterite>
Don't worry, we are all volunteers here
<asterite>
in time we'll fix everything
<jhass>
well, it means I can't update which is bad because I use my package which I do need to update...
<asterite>
In any case the use of Thread and IO.select will probably disappear or change, so...
<asterite>
Or we'll fix it
<jhass>
it won't, I will bring it back as library the moment I find the time to
<asterite>
Ok, as you wish :-)
<jhass>
having every crystal program that does a simple puts have to depend on libevent and libpcl is a bit insane
<asterite>
What was the problem with IO.select? I think waj told me that now it might block forever
<jhass>
yeah, it never returns
<asterite>
waj eventually wants to rewrite those things himself, maybe using inline assembler… or at least part of those
<asterite>
Why is it a bit insane? Go programs always statically link everything and are huge, and not many people complain
<vikaton>
asterite, will the 0.7.0 package have libevent and such ?
<jhass>
but if we're honest that'll take a year or so
<asterite>
Yes, it will have libevent and libpcl
<asterite>
But I don't think having Thread, Mutex and those synchronizations mechanisms as the default in the language make sense nowadays...
<asterite>
Other concurrency models are by far superior and safer
<asterite>
and threads don't scale
<jhass>
you know I have no issue with a slim and focused stdlib
<vikaton>
is the installation process updated to 0.70 ?
<jhass>
it's just that I currently don't have the time to do it as a library proper
<asterite>
Well, you won't have to use libevent nor libpcl directly, so that makes the std slim. Those are just implementation details, probably temporary until we find a better solution. The same as the GC
JBat has quit [Quit: Computer has gone to sleep.]
<jhass>
and as much as I agree with you that you should be opinionated about stdlib, as much do I still see value in the well understood classic concurrency primitives
<jhass>
I do have to learn a concurrency paradigm that's new to me and that's new for many people coming from the classic languages
<jhass>
that's not a bad thing, but it makes the entry barrier higher
<jhass>
and currently I don't want to rewrite DeBot for example
<asterite>
Our experience is, we had a bunch of critical Ruby on Rails app that eventually became very slow and couldn't scale. We had to rewrite portions of those in Erlang or Go
<jhass>
with the classic threading primitives I could just write it down, I didn't need to think much about the design because I understand those primitives well
<asterite>
Ruby couldn't scale because it didn't have a good concurrency model
DerisiveLogic has joined #crystal-lang
<jhass>
you misunderstand me, I'm not saying you shouldn't do it
<asterite>
So it's just an opinion?
<jhass>
and a major inconvenience for me atm, yeah
<asterite>
OK. Don't worry, I really like DeBot and once we stabilize things, you can be sure I'll send a pull request to make it work with the new concurrency model
<vikaton>
asterite, is the installation process updated to 0.7.0 ?
<asterite>
I'm currenly preparing the release
<asterite>
the tag has to come before that :)
<jhass>
so I have a couple short term options atm: 1) do not update the AUR package, that's a nogo, 2) stop developing DeBot since I can't recompile it with the updated compiler 3) have an old compiler unpackaged somewhere and take care to use it to recompile DeBot 4) Completely rewrite the bottom layer of DeBot 5) Do crystal-posix-io now
<jhass>
maybe you can see that neither is really attractive to me
<asterite>
That's because in arch you can't use an old package?
<jhass>
well, 3b) is create a package for the old compiler
<jhass>
which means I can't use new compiler features and fixes in it
<jhass>
but I'll probably go for 3
<asterite>
What if we try to make DeBot work, together, so we can fix and improve the spawn and channels support?
<asterite>
DeBot would be a good use case
<jhass>
after all it's a toy project for me still and I just can't justify the time atm, sorry
<jhass>
and I'm now convinced that I'll do crystal-posix-io anyway when I find the the time and nobody else comes first
<jhass>
I just want to have that available as an option, not as an recommended one but I don't want the language to loose it
<asterite>
Sounds good
<travis-ci>
manastech/crystal#2274 (master - 0df531e : Ary Borenszweig): The build is still failing.
<asterite>
I should probably say this now, I'll be taking a break from the computer for about two months. I'll try to reply emails and github issues, but I won't probably be coding at that time. But waj will be around answering and maybe programming
ponga has joined #crystal-lang
<vikaton>
Oh okay
<vikaton>
how can I test non-blocking IO ?
<vikaton>
and is it something thats just in the language or something that you implement?
<asterite>
non-blocking IO works out of the box, you don't have to do anything
<vikaton>
ooo
ponga has quit [Read error: No route to host]
BlaXpirit has quit [Ping timeout: 256 seconds]
ponga has joined #crystal-lang
BlaXpirit has joined #crystal-lang
<BlaXpirit>
asterite pls :(
ponga has quit [Read error: No route to host]
leafybasil has joined #crystal-lang
<BlaXpirit>
that's not the answer
ponga has joined #crystal-lang
ponga has quit [Read error: No route to host]
<vikaton>
asterite, remember that benchmark I did earlier with Node.js and Crystal? lol
ponga has joined #crystal-lang
ismaelga has joined #crystal-lang
ponga has quit [Read error: No route to host]
ponga has joined #crystal-lang
ponga has quit [Read error: No route to host]
<vikaton>
Crystal kills now
ponga has joined #crystal-lang
ponga has quit [Read error: No route to host]
ponga has joined #crystal-lang
ponga has quit [Read error: No route to host]
<vikaton>
>> "hello".t("h","k")
<DeBot>
vikaton: Error in line 3: undefined method 't' for String (did you mean 'tr'?)
ponga has quit [Read error: Connection reset by peer]
<BlaXpirit>
accidentally nillable types are a pain though :s
ponga has joined #crystal-lang
ponga has quit [Read error: No route to host]
<asterite>
BlaXpirit: awesome!!
ponga has joined #crystal-lang
<BlaXpirit>
looks a bit nicer than the C-ported SDL-based one :p
<BlaXpirit>
i mean code
<vikaton>
I wish I can try it
<asterite>
I did `crystal deps; crystal tetrominos.cr` and it worked :)
<vikaton>
but sadly, windows and a debian vps wont help ;-;
<BlaXpirit>
good, asterite
<asterite>
The code is really short
ponga has quit [Read error: Connection reset by peer]
ponga has joined #crystal-lang
<asterite>
what are accidentally nillable types?
<BlaXpirit>
when I know a variable can never be nil, but the compiler doesn't
ponga has quit [Read error: No route to host]
<BlaXpirit>
in any case, I wish there was a shorter way to deal with that than .not_nil!
<asterite>
Oh, I see for example `if @part`
<asterite>
In those cases you should assign to a local variable
<asterite>
for example: `if part = @part; …; else; … end`
<asterite>
Look
ponga has joined #crystal-lang
<asterite>
Well, nevermind
<asterite>
The usual approach is to assign an instance variable to a local variable. It can be inside the if or outside. Then the compiler knows the "nilable" status of local variables