pawnbox_ has quit [Read error: Connection reset by peer]
<crystal-gh>
[crystal] firejox closed pull request #3723: fix unexpected behavior in Slice(T)[] with T is numeric type (master...fix-unexpected-slice) https://github.com/crystal-lang/crystal/pull/3723
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 268 seconds]
pawnbox_ has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
crystal-lang856 has quit [Ping timeout: 260 seconds]
pawnbox has quit [Read error: Connection reset by peer]
<FromGitter>
<Exilor> bmcginty: nope :worried:
pawnbox has joined #crystal-lang
vivus-ignis has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<FromGitter>
<yxhuvud> You should be able to get that from libc though, so while it may not be nice to work with, it may be good enough for now until someone implement it in the language
<FromGitter>
<Exilor> I've tried to mess around with LobC.clock_gettime but i'm not getting the results i get with java
<FromGitter>
<Exilor> i'd think it'd be something like (timespec.tv_nsec.to_i64 + (timespec.tv_sec.to_i64 * 1e+9).to_i64), but nope
<FromGitter>
<Exilor> i went looking for how java implements it and it appears to be the same way
<mooe>
is it possible to get the remote ip with http server/kemal?
<FromGitter>
<Exilor> mooe: if you have access to the socket shouldn't you be able to call .remote_address.address on it?
<FromGitter>
<sdogruyol> @mooe it's still not yet merged into Crystal
<FromGitter>
<sdogruyol> however you can get Host from HTTP headers (hopefully)
<mooe>
alright cool, I tried x-real-ip, didn't know about host, thanks!
<FromGitter>
<jots_twitter> @Exilor : I see. Yeah not sure what that java nanotime is. if I divide crystal's nanotime by 1_000_000_000 I get correct unix epoch time.
<pleiosaur>
what types in crystal, if any, are implicitly nullable? are types only nullable if I explicitly make a union with nil?
<FromGitter>
<Exilor> no type is implicitly nullable AFAIK
<FromGitter>
<sdogruyol> @pleiosaur the compiler will yell at you
vivus-ignis has quit [Quit: vivus-ignis]
<pleiosaur>
cool
mark_66 has joined #crystal-lang
akwiatkowski has joined #crystal-lang
Philpax has joined #crystal-lang
<Yxhuvud>
or well, it will yell at you if you try to call a method not present on nil.
soveran has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 268 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
mooe has quit [Quit: Connection closed for inactivity]
bjz_ has quit [Ping timeout: 264 seconds]
bjz has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<Yxhuvud>
Bleh. It is irritating that I cannot set instance variables to self in the constructor as it will be nilable then :/
fedruantine has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
pawnbox has joined #crystal-lang
matp has quit [Read error: Connection reset by peer]
matp has joined #crystal-lang
<FromGitter>
<bcardiff> You should be able. As long as it is the last assignment i think. If you make a call with self in the initialize all not assigned ivar upto that call will necessarily be nilable.
<Yxhuvud>
well it was more than one variable.
<Yxhuvud>
And there was no calls at all inside initialize.
<Yxhuvud>
But I'll happily take suggestions for how to implement doubly linked circular lists without placeholder classes (or putting not_nil! absolutely everywhere)
<Yxhuvud>
basically I want to set @nxt and @prev to self.
<Yxhuvud>
which I am not allowed to.
<Yxhuvud>
(and yeah, I realize this is abusing the hell out of the type system)
<crystal-gh>
[crystal] MakeNowJust opened pull request #3732: Add "expand" command to Crystal tools (master...feature/crystal-tool/expand) https://git.io/v1dpm
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
pawnbox_ has quit [Ping timeout: 248 seconds]
<FromGitter>
<bcardiff> @Yxhuvud, you can use `uninitialized` in this scenario to avoid some compiler checks and have self referencing instances. Like "trust me, I will assign it and nothing will go wrong", but if you screw up is your fault not the compiler's. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5857e450058ca96737668785]
<Yxhuvud>
It doesn't seem to work with two such variables.
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
bjz has quit [Max SendQ exceeded]
minus has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
bjz has joined #crystal-lang
Philpax has quit [Ping timeout: 248 seconds]
jee12 has joined #crystal-lang
<FromGitter>
<bcardiff> You are right, my bad. There might be a limitation with self. To avoid polluting the code you can try something like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ which wont polute only in the apareance, since `property!` expands with `#not_nil!`. [https://gitter.im/crystal-lang/crystal?at=5857e9ba0730ce6937e3f3ef]
boo has joined #crystal-lang
boo is now known as Guest56274
<Guest56274>
hi
Guest56274 has quit [Client Quit]
jee12 has quit [Ping timeout: 260 seconds]
<FromGitter>
<yxhuvud> Eh, but then I don't get setters. Lets leave it at that it isn't as simple as one could wish it to be.
<FromGitter>
<bcardiff> @yxhuvud granted, but `property!` expands to getter and setter. I don't follow you.
pawnbox has joined #crystal-lang
ponga has joined #crystal-lang
ponga has quit [Client Quit]
ponga has joined #crystal-lang
<Yxhuvud>
never mind, I misread the compilation error I got.
<FromGitter>
<petehuang> @crisward thanks, exciting to be here! i'm CS educated but not a dev, so will be looking to help the community through non-technical stuff. ideas appreciated!
<minus>
are stars even an indicator of anything
<minus>
+useful?
<FromGitter>
<crisward> I personally only star stuff I'm using in someway... more users is a good thing if that's what it means
<minus>
i star stuff i think is cool but i don't necessarily use. though it's likely proportional to real users anyway
<minus>
is there a good example that shows off crystal features? the Hellow World and HTTP Server examples in the docs are not exactly representative
<dom96>
crisward: that's a cool link
<dom96>
Would be interesting to compare git clone numbers between Nim and Crystal
soveran has quit [Remote host closed the connection]
<minus>
you don't need to clone the repo to try/use crystal though, so not sure how representative that is either
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter>
<crisward> <minus> That depends on the audience... I mainly do web dev so links to kemal would be cool. Though I suppose awesome crystal (https://github.com/veelenga/awesome-crystal) provides that kind of thing.
<dom96>
minus: then perhaps a combination of website download numbers and git clones.
<minus>
if it's not in distro repos, yes
soveran has quit [Remote host closed the connection]
<FromGitter>
<bcardiff> having stars helps in discoverability. One might choose to list languages in an article based on github stars in the absence of a better criteria. I think is useful but not in a formal way.
<minus>
it's a popularity indicator, yes, but not a (direct) usage indicator
<FromGitter>
<bcardiff> The only way to have proper stats would be to add google analytics or similar in the compiler, as brew is doing nowadays. But I woudn't say it's a way to go right now.
mgarciaisaia1 has joined #crystal-lang
<RX14>
I've been in the HN thread all day answering questions. There's a lot of support which is nice.
<minus>
i was thinking about suggesting that earlier, as a joke. if you ever do that i'll hate you
soveran has joined #crystal-lang
<FromGitter>
<bcardiff> I hope you don't mean it personally. :-). I am not against analytics in general. It gives you a way of making better decisions based on actual data/usage. brew is able to prioritize things better based on most used formulas for example. It is controversial for sure, but I get the other side of the story of collection anonymous usage data.
mgarciaisaia has quit [Ping timeout: 258 seconds]
soveran has quit [Remote host closed the connection]
<FromGitter>
<bcardiff> it was discussed at https://changelog.com/podcast/223 if you are interested. ⏎ Yet, I don't need you need to worry about it.
<minus>
it's fine if a) it's not using google analytics but something self-hosted and b) asks you for permission on first run
<RX14>
but make sure to read the readme on how it works
<minus>
nah, vim & crystal run works fine. slap it into a loop with inotifywait and i'm golden
<RX14>
sounds good
<minus>
nice type pattern matching there with "free variables" already, but i want more
go|dfish has quit [Ping timeout: 248 seconds]
<RX14>
any examples? I find the current behaviour quite nice
<minus>
i didn't mean from that feature, i'm just looking for more compile time features
<minus>
like emitting new code
<minus>
concepts also
go|dfish has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<RX14>
you can use macros to emit new code at compile time
<RX14>
its really quite powerfull
<minus>
aw, you can't associate data with enum constants (like Java)
<Papierkorb>
minus: This is actually one of the few features I like from Java, and I'd love to see it. However, you can add methods to enums and then do a case on `self` as "mapping"
<minus>
Papierkorb: yeah, it's the feature i miss most in other langs (read: C++). you can emulate it like that but it's dangerous (if you forget a constant)
<Papierkorb>
Yep that's why I meant it as work-around. Currently I'm too tired, but feel free to open a GH issue suggesting this. I've not asked other ppl yet about this so I don't know if people will like or dislike it :)
<RX14>
^
<RX14>
i would support it if implemented well
<BlaXpirit>
i dont understand what feature was just discussed
<RX14>
BlaXpirit, google java enums to get an idea
<RX14>
basically each enum value gets it's own signleton instance
<RX14>
with it's own methods and the like
<Papierkorb>
Also fits great into the "everything is an object" idea
<BlaXpirit>
i dont see a good use for that
<BlaXpirit>
maybe something that looks cool but nothing that can be easily done through other means
<BlaXpirit>
can't be
<minus>
i've used it before to map strings to factories. create an object of different subtype depending on a string. instaciating objects from json
<minus>
those blocks seem really great, but the 'discard superfluous args to yield' and 'block can control the control flow of the executing function' bug me
<Papierkorb>
That's copied from ruby, and those are great and really powerful features
<minus>
is the 'it's an extra arg and there can only be one of it and it's magically called when putting a yield statement' part also from ruby?
<Papierkorb>
"it's"?
<BlaXpirit>
wait what
<minus>
s/it's/the block is/
<RX14>
minus, blocks are inlined
<RX14>
so the whole block function is copied to the call site
<minus>
yeah, i figured, RX14. the idea of messing with the control flow still seems odd to me
<minus>
i'm sure it has its uses
<RX14>
it really does
<Papierkorb>
Enumerable#each
<Papierkorb>
As in, for practically everything in collections
<RX14>
it's the difference between contrinue; and break; in C
<RX14>
when the yield is in a loop
<RX14>
you can use `finally` to execute cleanup when yield uses break too
<minus>
mhm
<RX14>
which you should do anyway
<RX14>
because otherwise exceptions would break your cleanup code too
<minus>
can blocks capture variables? or just procs
<Papierkorb>
sure they can
<minus>
can procs be generic?
<Papierkorb>
Currently not, no. You can compare Crystal Procs to C++ lambdas iirc
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
<RX14>
if i empty cache and hard reload it fixes it
<minus>
that macro syntax is meh, too much text templating, though i don't really have a better suggestion
<RX14>
don't want to encourage macros too much#
<minus>
is there still a chance to replace them by something else?
<RX14>
ehh
<RX14>
i think current macros are pretty nice
<RX14>
macros should be optimized for small things, not massive invasive changes to code
<RX14>
it's meant to be a DRY-helper not a "let me rewrite your code for you"
<Papierkorb>
really whats wrong with the current macro syntax
<minus>
it's better than C++ metaprogramming at least
<minus>
but you can't alter the AST, can you?
<minus>
i saw that used in an opengl lib in nim, it wrapped all api calls with error checks + throw, that was quite nice
<FromGitter>
<bcardiff> Crystal docs was recently updated to last gitbook version. Definitely a cache issue.
<Papierkorb>
minus: The `method_missing` hook can do t hat
<BlaXpirit>
minus, well wrapping something into other code is exactly the type of things that the current macros excel at
<RX14>
minus, you can walk the AST and emit stuff even inside call chains using recursive macros
<RX14>
unfortunately thats pretty slow
<minus>
RX14: know of an example of that i can look at?
soveran has quit [Remote host closed the connection]
Hates_ has joined #crystal-lang
<FromGitter>
<petehuang> @bcardiff i'll be putting in some time on the docs...but wanted to get your perspective first: any high priority / obvious areas of improvement you would like to see?
soveran has joined #crystal-lang
dhk has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
bjz has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<FromGitter>
<crisward> Is there a simple way to parse a json file with deeply nested objects , update a value, and save it back as json?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<tilpner>
JSON.parse, update, then .to_json?
<FromGitter>
<crisward> JSON.parse returns JSON Any - if you try to set a value on json any, you get no = method
<FromGitter>
<crisward> though I may be doing something wrong
<RX14>
oh thats a solid point
<RX14>
you'll need to use parse_raw then maybe?
<RX14>
hmm
<RX14>
thats a pain
<RX14>
I would have to say just create mapping objects would eb the easiest
<maxpowa>
deeply nested mappings get really ugly tho
<RX14>
not really
<RX14>
they don't deeply nest
<RX14>
you just get loads of objects
<FromGitter>
<crisward> The json file is a bit unknown before I parse it, so mapping isn't that easy. I was looking to use a pull parser and recursively parse an object but it looked like something I'd expect to be in the standard library somewhere. Just checking it didn't exist.
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
trajing has quit [Ping timeout: 250 seconds]
dhk has quit [Quit: Leaving]
RX14 has quit [Ping timeout: 250 seconds]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
greengriminal has joined #crystal-lang
trajing has joined #crystal-lang
RX14 has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
mgarciaisaia1 has quit [Quit: Leaving.]
trajing has quit [Read error: Connection reset by peer]
RX14 has quit [Read error: Connection reset by peer]