jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
Human_G33k has joined #crystal-lang
ua has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 256 seconds]
f1refly has joined #crystal-lang
chachasmooth has quit [Ping timeout: 256 seconds]
chachasmooth has joined #crystal-lang
duane has quit [Read error: No route to host]
chachasmooth has quit [Ping timeout: 264 seconds]
chachasmooth has joined #crystal-lang
duane has joined #crystal-lang
postmodern has joined #crystal-lang
<postmodern> anyone know how spectator does equality checks? for some reason it's claiming the yielded Array of Tuples does not match Array of Tuples parsed from YAML. When I write the same code in a .cr file and build that, i get the expected results.
Dreamer3 has joined #crystal-lang
alexherbo2 has joined #crystal-lang
Dreamer3 has quit [Quit: Leaving...]
<FromGitter> <Blacksmoke16> so i couldnt sleep so i made this https://play.crystal-lang.org/#/r/9i03
<FromGitter> <Blacksmoke16> essentially just a wrapper of the `Spec` module that uses a more OOP approach, with some extra features
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9i04 updated, fixed parent tests not being included. Verbose output looks like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f2b8cb983a82b0f05a2f465]
duane has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 265 seconds]
<FromGitter> <grkek> @neutrinog Thank you mate
<FromGitter> <grkek> for using Grip
<FromGitter> <grkek> I haven't had much time to work on it + I had a car accident which messed up me badly
<FromGitter> <grkek> messed me up*
<FromGitter> <grkek> Grip has a routing advantage over kemal
<FromGitter> <grkek> Plus that I will add static route handling via a hash and not a radix tree so we might see a speed gain as fast as the router.cr
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Remote host closed the connection]
zorp_ has quit [Ping timeout: 256 seconds]
<postmodern> is there a way to convert a slice to a pointer of a different underlying type?
deavmi has quit [Read error: Connection reset by peer]
deavmi_ has joined #crystal-lang
deavmi_ has quit [Read error: Connection reset by peer]
<FromGitter> <naqvis> `slice.to_unsafe.as(Type)` ?
<yxhuvud> .as(Pointer(Type)), rather.
deavmi has joined #crystal-lang
<postmodern> ah forgot about .as, nice
<postmodern> dumb questio, but the docs for Pointer(T).malloc don't seem to specify the type it returns? https://crystal-lang.org/api/0.35.1/Pointer.html#malloc(size:UInt64)-class-method
<Rounin> postmodern: I'm no crystal expert, but wouldn't T be the type?
<Rounin> Seems like some kind of generic method
<Rounin> I'm going off my Java knowledge here, but it seems like you might do something like... Pointer(Integer).malloc(100), say
<Rounin> Kind of sort of maybe
<postmodern> but does Pointer(T).malloc return Pointer(T) or Slice(T), since malloc is typically given a size (really a length)
<Rounin> postmodern: Ah, I see... Beyond me, I didn't know Crystal had malloc
<postmodern> according to `p Pointer(T).malloc(N)` returns a Pointer(T)
oddp has joined #crystal-lang
<oprypin> postmodern: if u want slice, do Slice.new
<postmodern> oprypin, i was more interested in the fact the documentation wasn't totally accurate; and it should be totally accurate.
<oprypin> postmodern: yea the documentation doesn't specify return types very often. tell me something new
<postmodern> could i fix that by just adding ` : Pointer(T)`? I can submit a PR if it's that simple.
<postmodern> (trying to avoid submitting incorrect PRs
<oprypin> such particular PR sounds good
duane has joined #crystal-lang
<FromGitter> <asterite> postmodern: it's a primitive and we forgot to add a return type, but it returns `Pointer(T)`. Maybe I tried adding a return type and it didn't work, I can't remember
duane has quit [Ping timeout: 256 seconds]
<FromGitter> <j8r> omg: ⏎ ⏎ ```a = [] of {String, Int32} ⏎ b = {} of {String, Int32} => Int32``` [https://gitter.im/crystal-lang/crystal?at=5f2c140071c83e6f0fc17b3d]
<FromGitter> <j8r> this syntax is so brainfuck for me x(
<FromGitter> <naqvis> indeed it is :P
<FromGitter> <Blacksmoke16> a tuple as a hash key? :p
<FromGitter> <j8r> yeah,t tat's possible in case of a matrix
<FromGitter> <j8r> for sparse ones
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <j8r> I agree that's uncommon though :)
postmodern has quit [Quit: Leaving]
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
sorcus has quit [Ping timeout: 244 seconds]
duane has joined #crystal-lang
sorcus has joined #crystal-lang
andremedeiros has quit [Quit: ZNC 1.8.1 - https://znc.in]
andremedeiros has joined #crystal-lang
andremedeiros has quit [Quit: ZNC 1.8.1 - https://znc.in]
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
zorp has joined #crystal-lang
andremedeiros has joined #crystal-lang
<FromGitter> <wyhaines> Oh. That's fun. I can't think of a specific use for it right now, but that is fun.
renich has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> is there an idiomatic or technical advantage to either of these alternatives? ⏎ ⏎ ```"some text".to_yaml builder ⏎ builder.scalar "some text"``` [https://gitter.im/crystal-lang/crystal?at=5f2c65c8107f3a0efab29ad5]
<FromGitter> <Blacksmoke16> mm id say if you already have the builder just use that
<FromGitter> <Blacksmoke16> the first one essentially just does the 2nd
<FromGitter> <dscottboggs_gitlab> yeah that's where I've been leaning, but I was also thinking like ⏎ ⏎ ```"some text".to_yaml builder ⏎ some_hash.to_yaml builder``` ⏎ ⏎ Might seem more consistent [https://gitter.im/crystal-lang/crystal?at=5f2c6d6571c83e6f0fc285cf]
<FromGitter> <Blacksmoke16> True
duane has quit [Ping timeout: 240 seconds]
renich has quit [Quit: Leaving.]
renich has joined #crystal-lang
postmodern has joined #crystal-lang
renich has quit [Quit: Leaving.]
<postmodern> what is the crystal equivalent of `.map(&Foo.method(:bar))`?
<FromGitter> <Blacksmoke16> mm what is it doing?
<FromGitter> <Blacksmoke16> calling `Foo.method` with the argument of `:bar` for each value in the array?
<postmodern> getting the method .bar on Foo and passing it as a block.
<FromGitter> <Blacksmoke16> uhh
<FromGitter> <Blacksmoke16> im going to say you cant do that
<FromGitter> <Blacksmoke16> would have to be like `.map { |item| Foo.bar item }`
<postmodern> so no fancy silliness like `.map(&->Foo.bar)` or something
<postmodern> wow the fact that protected methods can be called by objects within the same namespace is nice
<postmodern> exactly what i was looking for to hide an internal API that other objects need to call back to
<FromGitter> <Blacksmoke16> there is `&->` but idt it works for methods off another type other than whats on local scope
<FromGitter> <dscottboggs_gitlab> postmodern, if the type of the value yielded by `#map` in this case is `Foo` then you could do `map &.bar`
<FromGitter> <dscottboggs_gitlab> but in Crystal methods are tightly bound to their defining structure/class -- you can't, for example do `someClass.method.call(someObject, arg)` like you can in javascript
<postmodern> dscottboggs_gitlab, but would that be considered good/readable crystal?
<FromGitter> <dscottboggs_gitlab> `map &.bar`? Yes, it's commonly used.
<postmodern> also really liking the fact that you can combine protected methods with overriding to hide more complex internal methods of the same name. Very handy!
<FromGitter> <dscottboggs_gitlab> I agree!
<FromGitter> <Blacksmoke16> `private` would be better if that method is only intended to be call within `self`
<FromGitter> <dscottboggs_gitlab> I agree with that as well, I almost never use `protected`
<FromGitter> <Blacksmoke16> i use it a lot at work in PHP land, mainly since private methods are available to child types
<FromGitter> <Blacksmoke16> aren't*
<postmodern> protected is really handy in my usecase where i have this Device class that defines internal API methods that invoke ioctls on an fd, but I also have other classes like Buffer that have to invoke internal methods from Device
<postmodern> i could technically move the Buffer specific ioctls into the Buffer class, and use @device.fd, but i feel like keeping that low-level ioctl logic in Device is better. protected lets me hide the messy API details
<FromGitter> <Blacksmoke16> :shrug;
<FromGitter> <Blacksmoke16> and related to thing i made last night, im making it shard. I think its pretty neat :p
<FromGitter> <Blacksmoke16> ill put something on the forums when its done in next day or so
<yxhuvud> postmodern, I trust you saw the sections on proc_literal and blocks_and_procs in the gitbook?
<FromGitter> <Blacksmoke16> :0
<FromGitter> <Blacksmoke16> neat
oddp has quit [Ping timeout: 240 seconds]
<yxhuvud> The requirement to specify types can be a hindrance in certain situations though.