RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<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?
DTZUZO has quit [Ping timeout: 244 seconds]
<FromGitter> <Timbus> Does =~ return an int?
<oprypin> i'm sorry what
<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]) }`
<hightower2> Great, thanks!
<FromGitter> <Timbus> crystal eval 'val = "okay" && false; puts val' ⏎ false
<FromGitter> <Timbus> i mean, thats what I meant though
<oprypin> && could do better type filtering
<oprypin> you are right, i didnt understand at first
<Groogy> how is it, @var = SomeHelper.new(self) still don't work right?
<Yxhuvud> in initialize? No. some fields of self may not be initialized yet
<Groogy> yeah I know, just been gone for a while and saw the version had been bumped
<Groogy> and maybe someone had cleverly figured something out
<Groogy> hmm delegate doesn't work on block methods like #each, #map, etc?
<FromGitter> <Sija> @Groogy it should
<Groogy> get some problems with the arguments
alex`` has joined #crystal-lang
<FromGitter> <Sija> yep, there are some inconsistencies in how yield arguments are handled
<FromGitter> <Sija> might be a bug though
<oprypin> Groogy, no i dont think it works
<oprypin> the macro probably uses *args **kwargs but that is not aware of blocks
<FromGitter> <Sija> @oprypin it is, yet it passes `*yield_args` which don’t work since `Array#map` yields single entry and not a `Tuple`
<FromGitter> <Sija> see https://play.crystal-lang.org/#/r/4ryy for instance, where it does work with blocks
return0e has joined #crystal-lang
return0xe has quit [Ping timeout: 240 seconds]
<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> no it's not right lol
<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> <shayneoneill> ``` user = User.first ⏎ user.should_not be_nil``` ⏎ ⏎ Its using the granite orm. Theres one record in the table. [https://gitter.im/crystal-lang/crystal?at=5b7968b3802bc42c5f3eae66]
<FromGitter> <Sija> looks allright, problem must be someplace else
<FromGitter> <Sija> and the stacktrace?
ua has joined #crystal-lang
<FromGitter> <Sija> btw, amberframework/amber might a better place for such troubleshooting since it’s an Amber ORM you’re using
<oprypin> wow
<FromGitter> <Sija> that’s a strange shit indeed
<oprypin> did you define an `object_id` method anywhere?
<FromGitter> <shayneoneill> Yes. Its one of the fields in the table
<FromGitter> <shayneoneill> Ahhhh goddamn it, let me guess, its reserved by something
<oprypin> yeah..
<FromGitter> <shayneoneill> fsk sake
<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> <shayneoneill> Like Heres the code ``` ⏎ class User < Granite::Base ⏎ adapter pg ⏎ field username : String ⏎ field password : String ... [https://gitter.im/crystal-lang/crystal?at=5b7971c3dd0b74601e2c2634]
<FromGitter> <shayneoneill> (The object_id here refers to a remote resource url)
<FromGitter> <shayneoneill> See the problem?
<FromGitter> <shayneoneill> field itself is just a macro that expands out to create accessors to pull things in and out of the table row.
<FromGitter> <Sija> yeah @shayneoneill, cool your boots, you made it clear already in https://gitter.im/crystal-lang/crystal?at=5b796c44802bc42c5f3ebdba
knight- has quit [*.net *.split]
dom96 has quit [*.net *.split]
robacarp has quit [*.net *.split]
dom96 has joined #crystal-lang
<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")]`
<FromGitter> <schoening> Oh, this? @[JSON::Field(key: "lat")] ?
<FromGitter> <bew> Yess ;)
<FromGitter> <schoening> Cool I try it, thanks :)
DTZUZO has quit [Ping timeout: 272 seconds]
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.2]
alex`` has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 272 seconds]
Raimondii is now known as Raimondi
<hightower2> is there a crystal build for ppc64le?
<hightower2> (linux)
<FromGitter> <bew> ppc64le is a kind of powerpc right?
<hightower2> yes (little endian). For workstations like https://raptorcs.com/TALOSII/
<RX14> no
<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
alex`` has quit [Quit: WeeChat 2.2]
<RX14> thats the issue for porting to ppc64le
<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
<Vexatos> I mean I certainly did
<Vexatos> Not that I have gitter open that much