<FromGitter>
<j8r> The good point to static linking is you have a stable executable, that doesn't depend on whatever libraries or system it is running. Bad point is size, and easy upgrades for libs
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
<FromGitter>
<Qwerp-Derp> How do I send a Crystal array of UInt32s to a C function as a list of UInt32s?
Kug3lis has quit [Ping timeout: 240 seconds]
akaiiro has quit [Ping timeout: 268 seconds]
_whitelogger has joined #crystal-lang
akaiiro has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 272 seconds]
Raimondii is now known as Raimondi
hightower2 has joined #crystal-lang
<hightower2>
Hey, why is typeof() the following: [ "a", "b", "c"].map {|e| e=~ /^(.)/ && $1.to_s }.compact a Array(Int32|String) instead of just Array(String), especially when I have that $1.to_s there?
<FromGitter>
<Timbus> Was replying to hightower's q.
<oprypin>
apparently yeah, it returns an int for the position
<FromGitter>
<Timbus> I guess, without thinking too deeply about it, `&&` expressions should only ever return nil, false, or the last thing they evaluate. but yeah that seems hard, so it just returns all types
Groogy has joined #crystal-lang
<oprypin>
Timbus, that's not what happens and it's not even hard to make it how you describe
<oprypin>
`a && b` -> `a ? b : a`
<oprypin>
hightower2, i would recommend `["a", "b", "c"].compact_map { |s| s.match(/^(.)/).try(&.[1]) }`
<lvmbdv>
anyone working on an activitypub implementation?
<lvmbdv>
bc i wanna do that :^)
DTZUZO has joined #crystal-lang
<FromGitter>
<Aaron-JM> hey
<FromGitter>
<shayneoneill> Question. I'm working on some specs and don't know how to handle nils. Particualrly a DB query has a possibility of returning a nil if its wrong so I want to do something like result.should_not be_nil . The problem is I cant quite work out how should or should_not be_nil could work, cos Nil doesn't have any way to have a .should method, I think?
<FromGitter>
<Sija> @shayneoneill it does, since `#should` is defined on `Object`
<FromGitter>
<shayneoneill> But isn't Nil just a nothing? Like, zero pointer?
<FromGitter>
<Sija> Semantically that’s right, but it’s still an `Object`
<oprypin>
shayneoneill, nil is a value of the type Nil, that's all
<oprypin>
(the only possible value)
<FromGitter>
<Sija> and still an Object
<FromGitter>
<Sija> lol yrself ;)
<FromGitter>
<shayneoneill> Huh.
<FromGitter>
<shayneoneill> Well I'm definately getting some strange shit. If I just go u = User.first. No problems. But if I try and test it for nulity I get an error complaining about " wrong number of arguments for 'Nil#to_s' (given 2, expected 0..1)"
ua has quit [Ping timeout: 260 seconds]
<FromGitter>
<Sija> could you post offending code fragment?
<FromGitter>
<Sija> nice detective work @oprypin! ;)
<oprypin>
that's quite a weakness of the language though :/
<oprypin>
thanks
<FromGitter>
<shayneoneill> Actually this explains a whole boatload of strange behaviors that I've had (including the strangebehavior that motivated me to stop being lazy and write some tests)
<FromGitter>
<shayneoneill> This is by the way where I really do prefer the python convention of _ and __ for magic methods, reduces namespace polution
<FromGitter>
<shayneoneill> I swear to god not colliding with predefined methods injected into every damn object in the system , in ruby on rails is like trying to register a dot com. Gotta get creative.
<FromGitter>
<Sija> :D
<FromGitter>
<Sija> ns collisions are a common problem, if you use attribute notation (along with `method_missing` in this case) you’ll always be prone to end up with ‘em sooner or later, it’s just much less common to have fields named like `to_s` or sth like that, `object_id` OTOH is a perfect candidate for those (collisions)...
<FromGitter>
<shayneoneill> yeah its kind of an obvious candidate of something to implement for giving or refering to an objects id
<FromGitter>
<Sija> one solution for instance would be to use an index accessor (`#[]`), turning those into `User.first[:object_id]`
<FromGitter>
<shayneoneill> idea: A compiler flag to raise warnings when a method is redefined, along with perhaps a mechanism to flag it as known and goods
<FromGitter>
<Sija> you can always file up a ticket in Granite repo...
<FromGitter>
<shayneoneill> I dont think its a granite issue. object_id is part of the base object in crystals api, and its a problem here, cos I have a table field named object_id, which I now have to refactor and rename
<FromGitter>
<shayneoneill> But a compiler flag to throw up a warning when overwriting already existing methods would be useful to flag it in advance.
<FromGitter>
<Sija> well, it is since it’s the Granite which (re)defines this method
<FromGitter>
<shayneoneill> Yeah but granite isnt redefining it. I redefined it.
<FromGitter>
<shayneoneill> (cos I didnt know it was reserved)
<FromGitter>
<Sija> so you had your `def object_id` in the code?
<FromGitter>
<Sija> or you just had a field named like that?
<FromGitter>
<shayneoneill> No, I had a field named object_id
<FromGitter>
<Sija> so it’s Granite then
<FromGitter>
<Sija> that’s how you’re able to use `model_object#field_name` property notation
<FromGitter>
<Sija> in your case `User#object_id` but that’s up to Granite to make it work like that
<FromGitter>
<shayneoneill> Theres literally nothing they could do to prevent a user from doing it short of some kind of metaprogramming fuckery to scan peoples code. s
<FromGitter>
<Sija> wrong, it’s enought to use for instance `#[]` as I said before
<FromGitter>
<Sija> in this way you’d need to use `user[:object_id]` instead of `user.object_id`
<oprypin>
Sija, but type info would be busted
<FromGitter>
<Sija> and it would work with any property name
<FromGitter>
<Sija> @oprypin true that
<FromGitter>
<Sija> didn’t thought of that
<FromGitter>
<shayneoneill> Yes, but it would be *strange* to throw away the whole concept of object mapping and replace it with pseudo hashes just because someone might name a field the same thing as a reserved word.
<FromGitter>
<Sija> sure it would, hard to comeup with fully bullet-proof solution
<FromGitter>
<schoening> Trying to Generate JSON data from some classes but I need the properties to start with an Uppercase letter. What should I do? Do I have to use some JSON builder instead?
<FromGitter>
<bew> You can specify the key to use
<FromGitter>
<schoening> Right now all I do is *include JSON::Serializable* in my classes. Where would I specify this? Is there an example?
<FromGitter>
<bew> Above each properties, add `@[JSON::Field(key: "TheKey")]`
<hightower2>
any way to get involved? I wanted to try compiling it, but then saw the note that crystal is required to compile crystal, so kind of a dead end :)
<RX14>
it requires a lot of porting work inside the compiler and stdlib itself
<hightower2>
any docs roughly explaining the steps?
<RX14>
no because it's done so rarely
<RX14>
i can point you to the diff for supporting ARM but the rest is up to you
<hightower2>
great, please do!
<RX14>
the thing is that docs aren't really helpful
<RX14>
because anyone capable of doing it already knows what they need to do
<RX14>
it contains links to the other places you'll want to check
<hightower2>
cool, thanks
<FromGitter>
<bararchy> do we have a security@crystal-lang.com email?
<FromGitter>
<bararchy> ok found security@manas.tech
hightower2 has quit [Remote host closed the connection]
thews has quit [Excess Flood]
thews has joined #crystal-lang
thews has quit [Ping timeout: 244 seconds]
return0e has quit [Quit: Leaving]
thews has joined #crystal-lang
<FromGitter>
<druonysus_gitlab> is there an IRC channel?
druonysus has joined #crystal-lang
<FromGitter>
<druonysus_gitlab> hmmm... it seems #crystal-lang is a thing on Freenode but very few people in there... especially compared to here
<druonysus>
looks like gitter messages get proxied here... that is kinda nice!
<RX14>
yep
<RX14>
it's relatively few people but since we can both talk it all works out
<RX14>
I refuse to use gitter lol
<druonysus>
RX14: haha I am with you!!! Closed system vs a federated network on an open protocol... I pick open.
<Vexatos>
also: modding your client to heck so that the gitter relay is actually seamless
<RX14>
Also for me it's way easier because i'm on IRC anyway, and gitter is just one more program to have open all the time
<Vexatos>
same here
<RX14>
and yeah Vexatos wrote a script for hexchat to make the messages look like this: http://owo.sh/273c6e.png
<RX14>
so I barely tell the difference between who's on gitter and who's not, and you can also use @<tab> to complete people's usernames :P
<FromGitter>
<bew> Also on gitter the number of people is meaningless, because it's not the the number of people actually connected, but the number of people who ever joined the room
<druonysus>
oh that's interesting
<FromGitter>
<bew> And I guess most people just disable notifications for this room