Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pawnbox has quit [Ping timeout: 250 seconds]
pduncan has joined #crystal-lang
Philpax has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 276 seconds]
bjz has joined #crystal-lang
pduncan has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
balduin has left #crystal-lang [#crystal-lang]
pawnbox has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
vikaton has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
pabs has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
willl has joined #crystal-lang
kulelu88 has quit [Quit: Leaving]
DeBot has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 276 seconds]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Client Quit]
leftylink has joined #crystal-lang
Philpax has quit [Ping timeout: 265 seconds]
tombruijn has joined #crystal-lang
<FromGitter>
<anicholson> Hi everyone :)
<FromGitter>
<cjgajard> hello :)
<FromGitter>
<anicholson> I want to be able to pass a class as a parameter to a method (HTTP::Client, in my case) but I don't know how to get this past the type-checker. Is this something I should expect to be able to do?
<FromGitter>
<anicholson> ^ @BlaXpirit something like this?
Raimondi has joined #crystal-lang
<BlaXpirit>
`@client = T.new` but yes
<FromGitter>
<anicholson> but I don't _want_ a new T, I want to call methods on T directly!
<BlaXpirit>
oh then that's ok too
<BlaXpirit>
wait, you don't need an instance variable, what's the point
<BlaXpirit>
just T.get ...
<BlaXpirit>
i don't get why you even need a class then
<FromGitter>
<anicholson> @BlaXpirit I'm wrapping an OAuth flow and wanted to be able to inject a different HTTP client for testing purposes
<FromGitter>
<anicholson> and yeah, the `ivar` can go now
<FromGitter>
<anicholson> I'm coming from Ruby-land, so my thought process for encoding knowledge comes from somewhere else
<BlaXpirit>
i can see that
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter>
<anicholson> aha, perfect
<FromGitter>
<anicholson> thanks so much for the help, @BlaXpirit ! I wouldn't have gone to generics without your nudge :)
<FromGitter>
<anicholson> gotta loosen that "everything is an object" mentality
<FromGitter>
<cjgajard> little style thing... in https://carc.in/#/r/193t line 4 defines `@http_client` but in line 5 `http_client`is used instead, that is quite abusing of that syntax sugar...
<FromGitter>
<anicholson> @cjgajard yeah, I was just bashing out a proof-of-concept, so very sloppy style ;)
_whitelogger has joined #crystal-lang
bjz has joined #crystal-lang
_whitelogger has joined #crystal-lang
akwiatkowski has joined #crystal-lang
aolko has joined #crystal-lang
sapphire_brb has quit [Ping timeout: 240 seconds]
_jaitaiwan has joined #crystal-lang
<_jaitaiwan>
Sup guys... if I have a simple class which implements YAML.mapping, how can I get to_yaml to work with the class?
soveran has quit [Remote host closed the connection]
<_jaitaiwan>
@RX14 what about going through each instance variable and mapping to a hash? How would one go about that? I've tried a few things from ruby land but they don't seem to work
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
Raimondi has joined #crystal-lang
Philpax has joined #crystal-lang
<RX14>
_jaitaiwan, you either write that manually or use macros
Raimondi has quit [Ping timeout: 240 seconds]
<_jaitaiwan>
Is there some documentation or tutorials you can recommend? I'm at a loss as how to go about this. I've tried a few different methods to no avail
<RX14>
there's the macro syntax docs, then the macro object docs
<balduin>
RX14: yes, the pull operation can return nil, but in this case I made sure that first_list and second_list is not null
<RX14>
where did you make sure?
<balduin>
but every time I want to do something like content = first_list + second_list I still get an 'Nil' error
<balduin>
RX14 from a type perspective never, but through testing I know that first_list and second_list contain a string
<RX14>
i can't get the whole picture because I don't have the whole code with every class you reference so the only thing I can suggest is calling not_nil! on the pull call
<balduin>
@RX14: how would the 'not_nil!' look like?
<RX14>
it's a method call
<RX14>
on anything except nil it returns self
<RX14>
on nil it raises
<RX14>
@pip.pull.not_nil!
<RX14>
s/pip/pipe/
<balduin>
okay, thanks :-)
<balduin>
that was exactly what I was looking for
<balduin>
:-)
<balduin>
thanks :-)
<_jaitaiwan>
So I'm giving this macro thing a go... But I'm getting a syntax error and I can't for the life of me see why. Can I get a second pair of eyes please? http://pastebin.com/YkcgUcqG
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<BlaXpirit>
_jaitaiwan, the result of a top-level macro expression must be valid syntax
<BlaXpirit>
just a: b, c: d by itself is not valid syntax
<BlaXpirit>
so for a quick solution you should simply wrap the body of the method in {% begin %} {% end %}
qard_ has joined #crystal-lang
<_jaitaiwan>
interesting thanks
<BlaXpirit>
hm i need a way to get notifications for this channel, but in a way that doesnt ping for every single message
<_jaitaiwan>
most irc ones allow you to ping with your username?
qard has quit [Ping timeout: 265 seconds]
<BlaXpirit>
_jaitaiwan, well you needed help but of course you didn't mention me personally
<_jaitaiwan>
BlaXpirit: True :)
soveran has quit [Remote host closed the connection]
<RX14>
but basically adding begin and end stops `def to_yaml2` from becoming a `macro def`
<RX14>
normal macros don't have much access to type info because they run before the typing phase of the compiler
<RX14>
macro defs run after
<RX14>
@type confuses me
<_jaitaiwan>
RX14: me too...
<RX14>
you should make an issue on github asking for clarification from asterite because he probably knows what @type is set to where and why
<_jaitaiwan>
Yeah
<_jaitaiwan>
RX14 the hard part for me is that I'm trying to get the instance vars in a hash... but when I add a for loop to the same code above it crashes
<RX14>
lol what
<BlaXpirit>
RX14, it's simple what @type is
<BlaXpirit>
it is the current type that the method is in, and applies only to macro def
<BlaXpirit>
the only magical thing about @type is that it forces a macro def
<RX14>
nope
<RX14>
@type exists in normal macros too
<RX14>
especially hook macros
<BlaXpirit>
it cannot by definition
<RX14>
"When a macro is invoked you can access the current scope, or type, with a special instance variable: @type. The type of this variable is TypeNode, which gives you access to type information at compile time.
<RX14>
"
<RX14>
Note that @type is always the instance type, even when the macro is invoked in a class method.
<RX14>
from the docs
<BlaXpirit>
so..?
<RX14>
that implies it exists in normal macros
<BlaXpirit>
> A def is implicitly considered a macro def when you use @type inside a macro expression inside it.
<RX14>
yes
<RX14>
both these staements can be true
<BlaXpirit>
oh i should read better, you say normal macros, i thought about normal defs
<RX14>
...
<BlaXpirit>
but it wasn't really relevant to the situation
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kulelu88 has joined #crystal-lang
<Papierkorb>
Wrote a "broker" which accepts TCP connections and then publishes a string message to all connections at once. 10k clients (wrote that one in C), after ~3.6ms every client got the ~140Byte test message. Wanted to try Channels/Fibers. quite good results
<Papierkorb>
sdogruyol, I didn't write the server ("broker") in C, only the client to make sure I'm not measuring any overhead Crystals client could introduce over the plain C implementation
akwiatkowski has joined #crystal-lang
ponga has quit []
<RX14>
Papierkorb, can you write a broker in C nd compare?
<Papierkorb>
When I feel like, I could
<FromGitter>
<sdogruyol> Cool
Ven_ has joined #crystal-lang
<RX14>
now in erlang/elixir and nodejs too!
<RX14>
and run C1M while you're at ot :P
Ven_ has quit [Ping timeout: 264 seconds]
akwiatkowski has quit [Ping timeout: 244 seconds]
<FromGitter>
<sdogruyol> Lol
soveran has quit [Remote host closed the connection]
akwiatkowski has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Read error: Connection reset by peer]
soveran_ has joined #crystal-lang
<akwiatkowski>
How can I check if variable is uninitialized? By using var.uninitialized? ?
<RX14>
akwiatkowski, if you need to know, don't use uninitialized
<RX14>
if you don't know that it's set by the time of use you should be using nil instead
<akwiatkowski>
I'm not using it.
<RX14>
there is no way to tell
<akwiatkowski>
But it is used in kemal
<RX14>
what exactly are you trying to do?
<RX14>
work on kemal itself?
<akwiatkowski>
Run kemal spawned and wait till http server is ready. I think I'll check if there is open port.
<RX14>
uhh
<akwiatkowski>
I'm writing something like integration test
<RX14>
just wait 1ms
<RX14>
should be enough
<akwiatkowski>
ok
<akwiatkowski>
thx for convincing me
<RX14>
lol
<RX14>
i assume there's only 2 fibers
<RX14>
the main one and the kemal one
<RX14>
sleep 1ms will execute kemal until it blocks
<RX14>
and it's very likely that the first blocking operation for kemal will be waiting for HTTP requests
<RX14>
eh it's actually going to be the stdio write
<RX14>
but I would reckon that 1ms will be enough to ensure
<akwiatkowski>
I'll put 10ms to be sure
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 252 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
Ven_ has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit>
in fact, why should the proc change its type at all, even if it was before?
pawnbox has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Ping timeout: 250 seconds]
soveran_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 244 seconds]
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
pawnbox_ has quit [Ping timeout: 240 seconds]
<RX14>
BlaXpirit, because type = nil
<RX14>
idk
<RX14>
i guess that doesn't make sense
<RX14>
because you could do type = "" and type doesn't become Object
<RX14>
as in can be set to anything
<RX14>
so yeah
<RX14>
weird
<RX14>
i should report it but i need to get up early tomorrow so...
vikaton has joined #crystal-lang
Philpax has joined #crystal-lang
qard_ has quit [Ping timeout: 265 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Philpax has quit [Ping timeout: 244 seconds]
bew78 has joined #crystal-lang
<crystal-gh>
[crystal] asterite opened pull request #3294: Lift the restriction that type variables can only be single letter names (master...feature/relax_type_vars) https://git.io/viEtS