LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
splitty_ has quit [*.net *.split]
grindhold has quit [*.net *.split]
daekano has quit [*.net *.split]
aurelien has quit [*.net *.split]
greenbigfrog has quit [*.net *.split]
Kilo`byte has quit [*.net *.split]
Kilo`byte has joined #crystal-lang
splitty_ has joined #crystal-lang
daekano_ has joined #crystal-lang
grindhold has joined #crystal-lang
greenbigfrog has joined #crystal-lang
glenab has quit [Remote host closed the connection]
kiliankoe has quit [*.net *.split]
fedruantine has quit [*.net *.split]
bjmllr has quit [*.net *.split]
Liothen has quit [*.net *.split]
FromGitter has quit [*.net *.split]
z64 has quit [*.net *.split]
pabs has quit [*.net *.split]
jsaak has quit [*.net *.split]
buggs has quit [*.net *.split]
rkeene has quit [*.net *.split]
Papierkorb has quit [*.net *.split]
aemadrid has quit [*.net *.split]
Hates_ has quit [*.net *.split]
jfontan has quit [*.net *.split]
rkeene has joined #crystal-lang
jsaak has joined #crystal-lang
pabs has joined #crystal-lang
bjmllr has joined #crystal-lang
Papierko- has joined #crystal-lang
z64 has joined #crystal-lang
buggs has joined #crystal-lang
FromGitter has joined #crystal-lang
Liothen has joined #crystal-lang
fedruantine has joined #crystal-lang
aemadrid has joined #crystal-lang
kiliankoe has joined #crystal-lang
Hates_ has joined #crystal-lang
Liothen has quit [Changing host]
Liothen has joined #crystal-lang
jfontan has joined #crystal-lang
hmans has quit [Read error: Connection reset by peer]
jeromegn has quit [Read error: Connection reset by peer]
jeromegn has joined #crystal-lang
Majost has quit [Read error: Connection reset by peer]
avdi has quit [Read error: Network is unreachable]
jhass has quit [Ping timeout: 258 seconds]
Majost has joined #crystal-lang
hmans has joined #crystal-lang
M-mva1985 has quit [Ping timeout: 258 seconds]
acheron[m] has quit [Ping timeout: 258 seconds]
kodotest[m] has quit [Ping timeout: 258 seconds]
jhass has joined #crystal-lang
hako has quit [Ping timeout: 242 seconds]
hako has joined #crystal-lang
acheron[m] has joined #crystal-lang
M-mva1985 has joined #crystal-lang
kodotest[m] has joined #crystal-lang
avdi has joined #crystal-lang
aarongodin has quit [Ping timeout: 240 seconds]
aarongodin has joined #crystal-lang
hmans has quit [Ping timeout: 245 seconds]
hmans has joined #crystal-lang
kiliankoe has quit [Ping timeout: 245 seconds]
kiliankoe has joined #crystal-lang
<bmcginty_>
Anyone know of any really complicated c bindings that have unknown types being passed from a library back into crystal? I'm working on a bridge from javascriptcore (webkit's javascript engine, full es6 support) to crystal, like duktape.cr. Types come back encapsulated, and I'm going to have to decode them and turn into native crystal types and back again.
LastWhisper____ has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
<wmoxam>
pointer
<wmoxam>
whoops
unshadow has quit [Ping timeout: 240 seconds]
buggs has quit [Ping timeout: 240 seconds]
buggs has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
unshadow has joined #crystal-lang
unshadow has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 256 seconds]
unshadow has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
Kug3lis has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<manveru>
bmcginty_: not very complicated, but the tcl lib does that a lot
bjz has joined #crystal-lang
Kug3lis_ has joined #crystal-lang
Kug3lis has quit [Ping timeout: 240 seconds]
holyheels has joined #crystal-lang
glenab has joined #crystal-lang
glenab has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Philpax has joined #crystal-lang
Philpax_ has quit [Ping timeout: 246 seconds]
akwiatkowski has joined #crystal-lang
mark_66 has joined #crystal-lang
Yxhuvud has quit [Read error: Connection reset by peer]
Kug3lis_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Yxhuvud has joined #crystal-lang
Kug3lis has joined #crystal-lang
<Kug3lis>
Is there any way like to have shutdown handler, or class initialize opposite deconstruct of something similar?
akwiatkowski has quit [Read error: Connection reset by peer]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
soveran has quit [Remote host closed the connection]
gloscombe has joined #crystal-lang
Kug3lis has joined #crystal-lang
<manveru>
Kug3lis: i think you can do something like Signal::INT.trap{ your stuff }
<Kug3lis>
manveru I though about it but then if it quits with some different signal...
<manveru>
yeah... not ideal :(
bjz has joined #crystal-lang
bjz has quit [Client Quit]
<Kug3lis>
Also maybe someone has ideas how to count results from crystal-db query? I cant seem to see any method in ResultSet API
<manveru>
just looked and saw that that's how the spec lib does it
<manveru>
maybe TERM
Raimondi has quit [Read error: Connection reset by peer]
Raimondi has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
bjz has joined #crystal-lang
<manveru>
so many PRs, so little merge :(
<txdv>
manveru: are you interested in chipping in?
<manveru>
I can help a bit, sure
<manveru>
Not sure what the policy is yet though
<txdv>
changing a single bit wont be that helpful, multiple bytes of change are expected
<Yxhuvud>
IME uncontroversial PRs get merged pretty fast.
<manveru>
Lol
<manveru>
well, it's your choice, i'm not that experienced with crystal yet, even though it's so similar to ruby, but if it's just making sure that the PR is small and well-tested and uncontroversial, that i can do :)
<manveru>
right now i'm porting my programming language from neko to crystal and having fun doing that
<Yxhuvud>
hey, I'm not in charge. Just a very lowly contributor. The people in charge would be asterite and the other people at Manas.
<Yxhuvud>
argentineans, so they should start coming online soon.
<manveru>
heh, and elixir is from brazil
<manveru>
go south america!
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akwiatkowski has joined #crystal-lang
Kug3lis has joined #crystal-lang
<bmcginty_>
manveru: thanks. will look.
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 240 seconds]
<bmcginty_>
Kug3lis: def finalize on a class gets called when an instance is GC'd, i fthat's what you were referring t earlier today.
<manveru>
finalize doesn't run when the process exists though
<manveru>
*exits
<manveru>
fun fact: `crystal eval 'class X; def finalize; p :bye; end; end; 1335.times{ X.new }'` doesn't output anything, but with 1336 it does :)
<manveru>
might also depend on the machine
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<bmcginty_>
manveru: my bad. and it's odd. even given five or ten seconds of sleeping when finished, the gc never kicks in...
<manveru>
well, GC only should run when there's too many objects
<manveru>
but either way, you cannot rely on GC to call finalizers on program exit, at leat in no language i know of
<manveru>
so having some callbacks like BEGIN/END would be cool in crystal :)
<manveru>
for some reason i can't compile a program using that on my machine...
<Kug3lis>
manveru oh thanks man :)
<manveru>
and fixed it :)
glenab has joined #crystal-lang
<Kug3lis>
heh database stuff for crystal are so scarce...
bjz has joined #crystal-lang
glenab has quit [Ping timeout: 248 seconds]
gloscombe has quit [Quit: Lost terminal]
<FromGitter>
<raydf> @Kug3lis, you can call a count aggregate funtion sql query with the same variables than the resultset call. https://crystal-lang.org/docs/database/index.html max_age = db.scalar "select count(*) from contacts"
<FromGitter>
<raydf> this is very useful for paging situations
<FromGitter>
<raydf> because you can count first and then use LIMIT clause for selecting a subset of data.
gloscombe has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
FromGitter has quit [Ping timeout: 240 seconds]
Kug3lis has joined #crystal-lang
FromGitter has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
holyheels has quit [Read error: Connection reset by peer]
holyheels has joined #crystal-lang
<manveru>
so for shards there's no central repo?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Kug3lis has quit [Read error: Network is unreachable]
Kug3lis has joined #crystal-lang
<manveru>
btw having Hash#[] be Hash#fetch is so much nicer, in ruby i usually had a refinement for that because it's so annoying
<Yxhuvud>
You also have []? for when you want the other behaviour.
<manveru>
aye, quite neat :)
<manveru>
hmm, i'm trying to load a yaml file, add a key/value, and save it again
<manveru>
`undefined method '[]=' for YAML::Any`
<manveru>
guess i need to assert the type somehow?
<manveru>
hm, solved that i think
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
<manveru>
so... converting YAML::Any#to_h may result in a bunch of types
<manveru>
`undefined method 'find' for String (compile-time type is (Array(YAML::Type) | Hash(YAML::Type, YAML::Type) | String | Nil))`
* manveru
has flashbacks to Go
<manveru>
so i need a case statement there to assert it's an Hash
<FromGitter>
<cschlack> Hi all!
<FromGitter>
<cschlack> Is there a way to use a HTTP::Client with streaming (for HTTP::Request as well as HTTP::Response) without using the block syntax?
<FromGitter>
<cschlack> I would like to open a HTTP::Client, stream the request body, then stream the response body, then close the connection.
<FromGitter>
<cschlack> I can't use a block, because writing and reading the body is going to happen in callbacks (from a C library).
<FromGitter>
<mverzilli> I think it'll help you understand what's happening
<manveru>
ah, so i don't understand that type syntax right yet
<manveru>
thanks :)
soveran has quit [Remote host closed the connection]
unshadow has quit [Quit: leaving]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
LastWhisper____ has joined #crystal-lang
unshadow has joined #crystal-lang
<manveru>
another question, since i'm thinking of changing the crystal package for NixOS, should libyaml be a dependency of crystal or should each user be responsible for providing one?
<Papierko->
manveru: How does ruby do it?
<Papierko->
Not guaranteed to be the correct way, but maybe a pointer (note that I have no idea about Nix)
Papierko- is now known as Papierkorb
<manveru>
for the ruby package, yaml is optional, but on by default
cyjimmy264 has joined #crystal-lang
<manveru>
i think that'd be a good compromise, since most people want things to work out of the box :)
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
daekano_ is now known as daekano
soveran has quit [Remote host closed the connection]
kodotest[m] has quit [Remote host closed the connection]
M-mva1985 has quit [Remote host closed the connection]
acheron[m] has quit [Write error: Broken pipe]
braidn[m] has quit [Write error: Connection reset by peer]
TheGillies has quit [Read error: Connection reset by peer]
<unshadow>
So, I got this project: https://github.com/bararchy/fiber_pool, trying to create a multi-threaded fiber pool. but, it seems it crashes even on specs with invalid mem address, and other mem allocation issues, can someone help me figuring this out ?
<RX14>
unshadow, threads don't work
<RX14>
is the long and short of it
<Papierkorb>
Threading in Crystal 101: Don't
<RX14>
IO and GC and fibers don't work in threads
<RX14>
so just don't
<RX14>
Thread.new == segfault
<RX14>
basically
<unshadow>
That makes sense I guess hahaha
<unshadow>
Hm.... so fiber_pool without multi-threading is kinda useless :\
<unshadow>
guess I'll delete the project
<Papierkorb>
Also, fibers are almost free compared with threads, I don't know any benefit of using a pool for them
<unshadow>
If threads are not supposed to be touched, why not have them as "private" inside the STDlib or raise "dont do this!!" if Thread is called
<Papierkorb>
The only thing I added was automatic naming them for debugging purposes
<unshadow>
Papierkorb: the benefit was having multiple threads each having x fibers doing some work. if threads aren't usable, then I guess you are right
<Papierkorb>
That's what I expect the final Crystal-internal implementation to do by default
pduncan has joined #crystal-lang
braidn[m] has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
DeBot has quit [Remote host closed the connection]
DeBot has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
TheGillies has joined #crystal-lang
M-mva1985 has joined #crystal-lang
acheron[m] has joined #crystal-lang
kodotest[m] has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
Guest18334 is now known as Cyrus
Cyrus has quit [Changing host]
Cyrus has joined #crystal-lang
cyjimmy264 has quit [Ping timeout: 256 seconds]
<FromGitter>
<exts> Will crystal ever have something like this in the language? http://php.net/manual/en/reflectionmethod.invoke.php If not that's fine, i'll either stick w/ single action classes or use case expressions to solve something similar.
<RX14>
you can sort of use macros to do what you want
<RX14>
what exactly do you need this for?
Raimondi has quit [Quit: WeeChat 1.6-dev]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sirus has left #crystal-lang [#crystal-lang]
LastWhisper____ has joined #crystal-lang
<FromGitter>
<martinium> @RX14 I am looking to create a web interface that pipes inputs to a command line app running on a server. What would be the recommended way to go about this?
<FromGitter>
<exts> i'll show you in about 30 minutes when i upload it to github, i'm from the php world so I haven't really adapted to the ruby way of things so I approach mvc a little differently. ⏎ ⏎ With that said I do have a question, is there a way to do one liner initialize methods for classes that don't have a body?
LastWhisper____ has quit [Client Quit]
<FromGitter>
<exts> i worded that weirdly, i meant to say: is there a way to do one liner initialize methods for those without a body
<RX14>
@martinium well use Process to create a Process which uses the IO from the HTTP request
<RX14>
Process will accept an IO as stdin
<RX14>
you can also use context.response as stdout if you want
<FromGitter>
<martinium> So Process can send input to command line app and use context.response for the output
<RX14>
yes
LastWhisper____ has joined #crystal-lang
<RX14>
you might want to filter the process's output though
<BlaXpirit>
unshadow, didn't i tell you about all this right away?
<RX14>
the most expensive part of creating fibers is allocating memory
<RX14>
and the crystal scheduler keeps a pool of stacks around
<RX14>
so allocating fibers is essentially free
<BlaXpirit>
told that as well
akwiatkowski has quit [Ping timeout: 264 seconds]
Raimondi has joined #crystal-lang
<RX14>
@spalladino are there any docs on the new tags?
<FromGitter>
<bcardiff> @RX14 Coming soon
<RX14>
thanks
<FromGitter>
<bcardiff> we are tagging and discussing new tags over some open issues and later spalladino will drop some guidance on using them.
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
A124 has quit [Quit: '']
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
A124 has joined #crystal-lang
LastWhisper____ has joined #crystal-lang
<FromGitter>
<andrewhamon> Hey guys! I've been working on a HTTP router implemented as a normal HTTP::Handler/middleware
<FromGitter>
<sdogruyol> @andrewhamon that's cool
<FromGitter>
<andrewhamon> And I'm really not sure the best way to add additional context to the context object in a way that is friendly to other middleware that might want to do the same
<FromGitter>
<andrewhamon> In, i.e. Rack, its easy since its just a Hash that you can stick anything in
<FromGitter>
<andrewhamon> But in Crystal thats not an option. The available options are: ⏎ ⏎ 1) Monkey patch `HTTP::Server::Context` ⏎ 2) Subclass `HTTP::Server::Context` ⏎ 3) Wrap `HTTP::Server::Context` [https://gitter.im/crystal-lang/crystal?at=5873e0de873d96e16d47c455]
<FromGitter>
<sdogruyol> @andrewhamon 1 is the way to go
<unshadow>
BlaXpirit: Yes, you did tell me making a fiber pool is meangless, that's why I wanted to add multi-threading to it, which loops around back to what RX14 and I was talking about.
<FromGitter>
<andrewhamon> @sdogruyol so just monkey patch and hope I don't clobber anything?
<FromGitter>
<bcardiff> changing HttpServer to generic might have other limits. extensions might not me composed even if there concerns are orthogonal to each others.
<RX14>
you would make HTTP::Server generic and take a Context type which must extend from the original type, extensions then provide a module which you could mix in to the new Context type you create.
<FromGitter>
<sdogruyol> @unshadow :property ?
<RX14>
Frameworks would provide their own ready-made types
<Papierkorb>
Something like Hash(Class, Object) <- that won't work right now sadly, but something like that could work. It's a bit iffy to work with, but it'd work with anything and clashes are pretty much impossible
<FromGitter>
<sdogruyol> property
<RX14>
with the modules pre-included
<FromGitter>
<andrewhamon> RX14 in that case how would two libs, each with their own Context types, share a HTTP server?
<RX14>
i said they provide mixins
<RX14>
you just mix in both if you want 2 libs
<Papierkorb>
Then Kemal could add an instance of Kemal::MyContext, and another one would add Theirs::MyContext, and nothing clashes
<FromGitter>
<sdogruyol> yeah
<FromGitter>
<andrewhamon> I see, and it would be namespaced be the class in the theoretical Hash(Class, Object)?
<RX14>
Kemal::ContextMixin and then just `class Kemal::Context < HTTP::Context; include ContextMixin; end;`
<Papierkorb>
andrewhamon, in that pseudo-code, yes. Use the Class itself as key. I think I saw this in other languages.
<FromGitter>
<andrewhamon> I see, that would be pretty neat
<Papierkorb>
Though say `@params : Array(Param)`, with the object mapping to itself, and everyone just sub-classes the Param. And then a method which finds an object by its class. More hacky, but that could work with current Crystal
<Papierkorb>
though I guess you could also do Hash(String, Param) then, you "just have to be careful" that you choose unique names *hides*
<FromGitter>
<andrewhamon> A much less technical solution would be to just get everyone to namespace their monkey patched attentions
<FromGitter>
<andrewhamon> like `kemal_params` instead of `params`
<FromGitter>
<andrewhamon> ;)
<RX14>
context.kemal_params?
<RX14>
no thanks
<FromGitter>
<sdogruyol> hahahaha
<FromGitter>
<andrewhamon> Well, I need `params` for *my* lib, but I can't in good conscience use it
<FromGitter>
<sdogruyol> i laughed hard :D
<FromGitter>
<andrewhamon> Heres what I'm working on btw
<Papierkorb>
macro method_missing(name); params[{{ name.stringify }}]; end #yolo
<FromGitter>
<andrewhamon> So I'll probably monkey patch and add `crux_params`
<bmcginty_>
Is there a way to get Lib.func(out param) to have param initialized ot zero before running?
<bmcginty_>
Sorry, that was kind of goofy sounding. I've got a c library that has me pass a pointer to some initialized memory. I need this memory zeroed out, though, as it's (in the deep dark recesses of c) a pointer to a pointer already...and I need to check that the pointer is null when teh library function finishes.
<Papierkorb>
bmcginty_: I don't think so
<RX14>
@andrewhamon why not call it params for now, while you float the idea for extensibility on the github issue tracker
<bmcginty_>
Papierkorb: erg. okay. Thanks. think I'll go look for how the out stuff is implimented.
<FromGitter>
<andrewhamon> @RX14 Sounds good to me!
<FromGitter>
<bcardiff> @bmcginty_ if you want out with an initial value you might just want a pointer.
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
gloscombe has quit [Quit: Lost terminal]
triangles2 has quit [Quit: Leaving]
pduncan has joined #crystal-lang
<manveru>
i want to make a list of classes that inherited my class, i tried like this: `class X; @@x = [] of X; macro inherited; @@x << self; end; end`
<manveru>
but then i get `no overload matches 'Array(X)#<<' with type Hello:Class` for `class Hello < X; end`
<manveru>
i assume because at that point it's not inherited yet... but i can't make a `[] of Class` because crystal says that's too generic?
<manveru>
so... how would i do that instead?
<FromGitter>
<MaxLap> Since you are putting types in that array, i think you need `[] of X.class`? Pretty new to the language
<FromGitter>
<MaxLap> note that the code won't work like that for what you are doing. the @@x is duped between each subclasses. You would need your macro to do something directly on X
<manveru>
well, i plan to enumerate the methods on each subclass and print them first :)
<manveru>
your suggestion is already a good point
<FromGitter>
<MaxLap> class X; @@x = [] of X.class; macro inherited; class ::X; @@x << {{@type.name}}; end; end; end
<FromGitter>
<MaxLap> I think this is what you would want
<FromGitter>
<MaxLap> `class X; @@x = [] of X.class; macro inherited; class ::X; @@x << {{@type.name}}; end; end; end`
<manveru>
pretty close, but @@x seems to be empty on every invocation, so i think inherited is called on the child?
<manveru>
it works with a constant instead
soveran has quit []
<FromGitter>
<MaxLap> Yes, it's copied for every class, and type is the child, that's why my suggestion was adding them specifically to the class ::X. Yeah, the constant is probably easier
<manveru>
sorry, i missed the ::X
<manveru>
that makes a lot more sense :)
<manveru>
thanks
<manveru>
it's a bit hard for me getting used to this kind of compile-time-only metaprogramming... it's like a mix of what i saw in elixir and go
<manveru>
but i'm way more familiar with ruby ^^;
<FromGitter>
<MaxLap> Yeah, i understand. And the error messages aren't always as helpful as they could be
<RX14>
you can use .subclasses in macros
<RX14>
for example
<RX14>
{{Foo::Bar.subclasses}}
<RX14>
and thats all your subclasses
<manveru>
!
<RX14>
SUBCLASSES = {{Foo::Bar.subclasses}} might work