<adam12>
asterite: Thanks. I was just looking at docs now.
<adam12>
I wonder if there is a nice way to have local client/daemon communications without building my own protocol.
<adam12>
(ala UnixSockets)
Learod has joined #crystal-lang
Learod has quit [Quit: Page closed]
<FromGitter>
<drosehn> Ruby's kernel defines a method called __method__ (or __caller__ ), which gives the name of the current method. Does crystal have some similar feature?
Philpax has quit [Ping timeout: 244 seconds]
<FromGitter>
<drosehn> Oops. Hmm. '__method__'
<FromGitter>
<drosehn> well, it's the word 'method' with two underscores before it, and two after it!
<FromGitter>
<drosehn> I use it for quick debug messages, such as: ⏎ `printf "DBG: ... Called %s.%s\n", self.class, __method__`
Philpax has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit []
piotrb has joined #crystal-lang
<piotrb>
What's a good project/build system for crystal? seems like make .. but make .. is so .. 70's ..
<piotrb>
any cool new projects trying to fill that gap?
<adam12>
crake? tho last time I tried it, it wasn't updated and had build errors.
<foca>
piotrb: make
<foca>
it works, it's simple, it's straightforward
<foca>
there's NO POINT to keep reinventing that wheel (badly)
<piotrb>
I guess crystal is less messy .. its a monolithic compilation process so you're not juggling 100's of .o's
<foca>
there's a few things in make that are definitely improvable, but I feel like most of the seven hundred reimplementations of make that are around don't really address those issues, but instead are "I don't want to learn make so I'll rewrite it in <insert language>"
vrand has joined #crystal-lang
vrand has quit [Remote host closed the connection]
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: https://git.io/v6kO6
<crystal-gh>
crystal/master 3e5fa88 Ary Borenszweig: Replaced all `x as T` with `x.as(T)`
<crystal-gh>
crystal/master 3e62344 Ary Borenszweig: Removed the deprecated `x as T` syntax
<piotrb>
hmm .. different question .. been looking at C binding generators .. so far came across https://github.com/TechMagister/bindgencr and crystal_lib .. both seem to have issues .. crystal_lib seems more immature ..
<piotrb>
is there another?
pawnbox has joined #crystal-lang
onethirtyfive has joined #crystal-lang
piotrb has quit [Quit: Leaving.]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
emancu has joined #crystal-lang
<emancu>
hello! anyone online ?
<emancu>
I wonder why is this happening
<emancu>
require 'json'
<emancu>
expected = { "message" => "Hi!" }
<emancu>
body = "{\"message\":\"Hi!\"}"
<emancu>
res = JSON.parse body
<emancu>
puts expected == res # false
<emancu>
puts res == expected # true
<txdv>
interesting
pawnbox has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax has quit [Ping timeout: 276 seconds]
<jhass>
== is just a method call, it can be implemented however
<jhass>
in this case the metamodel is probably just broken though
<jhass>
all the .class stuff is just fake
<jhass>
ah no, nvm
<jhass>
Hash#== doesn't know about JSON::Any, but JSON::Any#== knows about Hash
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
emmanueloga has quit [Ping timeout: 276 seconds]
emmanueloga has joined #crystal-lang
Philpax has joined #crystal-lang
elomatreb has quit [Ping timeout: 250 seconds]
asterite has quit [Ping timeout: 264 seconds]
DeBot has quit [Ping timeout: 264 seconds]
asterite has joined #crystal-lang
elomatreb has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
zodiak has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
zodiak_ has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
DeBot has joined #crystal-lang
soveran has quit [Remote host closed the connection]
mif_ has joined #crystal-lang
soveran has joined #crystal-lang
mif_ has left #crystal-lang [#crystal-lang]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
trapped has joined #crystal-lang
pawnbox has joined #crystal-lang
ponga has joined #crystal-lang
<asterite>
I think JSON::Any should be much dumber, not having `==` and having `to_s` show `JSON::Any([1, 2, 3])` so it's clear it's a different type than the wrapped value
<asterite>
That could stop all the confusion around it
<BlaXpirit>
+
<asterite>
In fact, maybe JSON::Any is a bad idea... if you know what you are doing then it's fine, but otherwise it might not be very intuitive. Better to expose the raw union all the time and let the user deal with casts, which is probably simpler and the compiler can help with errors
<asterite>
It's more tedious to reach a node, but maybe it's clear what's going on
<BlaXpirit>
that's what i thought initially too. i think JSON::Any is a relatively recent addition, isn't it?
matp has joined #crystal-lang
<BlaXpirit>
but it's nice in a way, I'm not sure about it
<FromGitter>
<kofno> I'm using JSON:Any right now. I've just trying to get stuff out of it as quickly as possible, so it doesn't wind through all my code.
<BlaXpirit>
i hear ya
<BlaXpirit>
well it's great for prototyping
<FromGitter>
<kofno> Although, if JSON.mapping could be made a little smarter, I wouldn't use it at all.
<FromGitter>
<kofno> Actually, that statement isn't entirely true. But I would use it less.
<FromGitter>
<kofno> That said, it isn't awful. I'd just prefer a mapping mechanism that is a little more robust.
matp has quit [Ping timeout: 240 seconds]
Philpax has quit [Ping timeout: 258 seconds]
<jhass>
what's missing in mapping for you?
pawnbox has quit [Remote host closed the connection]
<FromGitter>
<kofno> Let me see if I can describe it for you:
<FromGitter>
<kofno> I get jsonrpc messages. If the json has an id field, I'd like to map to the ProcedureCall struct. If the id is absent, then I'd like it to map onto a NotificationStruct.
<RX14>
I think JSON::Any should stay
<FromGitter>
<kofno> There's another similar use case, but it amounts to "making a decision about which type to map to, based on the content of the JSON"
<FromGitter>
<kofno> So, for now, I'm using JSON::Any and case/when
<FromGitter>
<kofno> and manually mapping
pawnbox has joined #crystal-lang
<BlaXpirit>
this has been brought up before
pawnbox has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
<FromGitter>
<kofno> I think JSON::Any has a place for these scenarios where mapping isn't a good fit.
trapped has quit [Read error: Connection reset by peer]
<FromGitter>
<asterite> @kofno what is exactly the mapping for each of these classes? I think you could use a union in the mapping, but only if the fields are different
<FromGitter>
<asterite> but if one type is a subset of the other you'd need to pass `strict: true` after the properties (put them in a hash/named-tuple literal)
<FromGitter>
<kofno> OK... that actually helps a lot.
<jhass>
seems like a bug, feel free to open an issue
<hangyas>
ok, thanks
hangyas has quit [Quit: hangyas]
<RX14>
jhass, asterite already fixed it
<RX14>
on master
<jhass>
oh
<RX14>
i ran into it
<RX14>
there is already an issue
<jhass>
should've tested, couldn't be bothered :P
<RX14>
just closed
<adam12>
I don't see a way to do a scanf style read on IO. Can anybody look at this and see if there is a more optimal way? Could be nothing wrong with this way but I'm curious. https://play.crystal-lang.org/#/r/15bu
<jhass>
you mean more efficient in terms of LOC?
<jhass>
not sure what a scanf could do any better performance wise
<BlaXpirit>
I don't understand the usefulness of this concept anyway
<adam12>
Not performance, but reading the delimiter in and then chopping it, and then having to cast to Int32.
<adam12>
Was wondering if I could read it in one go, similar to scanf...
<adam12>
BlaXpirit: usefulness of netstrings?
<BlaXpirit>
yes
<adam12>
Socket communication without having to worry about framing.
<adam12>
.. how would you handle it? I'm not 100% sold on netstrings
<jhass>
in crystal scanf would return huge unions and probably an array
<jhass>
so you'd just trade one ugliness for another
<adam12>
jhass: Thanks - I'll deal with what I have then.
<BlaXpirit>
adam12, 4 bytes length, then the string...
<BlaXpirit>
or 7 bits length + 1 bit continuation if u know what i mean
<adam12>
BlaXpirit: Ah - I've done that in Ruby, but it eliminates the plain text nature of being able to use socat, etc.
<adam12>
but I agree, maybe that's a better solution here.
<BlaXpirit>
ok
mark_66 has quit [Remote host closed the connection]
willl has quit [Quit: Connection closed for inactivity]
<jhass>
asterite: #ruby just found an interesting edgecase in Ruby, fails differently but nonetheless interesting in Crystal too, not sure if worth fixing but sure fun :D https://carc.in/#/r/15f2