ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.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
jrayhawk has quit [Quit: leaving]
jrayhawk has joined #crystal-lang
olbat[m] has quit [Read error: Connection reset by peer]
beepdog has quit [Remote host closed the connection]
beepdog has joined #crystal-lang
<FromGitter> <didactic-drunk> Can different formats specify different converters? For example JSON doesn't have a universal time type and requires application specific serialization. YAML has a native datetime type.does support times and.
<FromGitter> <Blacksmoke16> Could still use property specific converters
<FromGitter> <Blacksmoke16> To control how a specific property gets serialized
alex``` has quit [Ping timeout: 246 seconds]
alex``` has joined #crystal-lang
commavir has quit [Remote host closed the connection]
commavir has joined #crystal-lang
return0e has quit [Remote host closed the connection]
alex``` has quit [Ping timeout: 250 seconds]
alex``` has joined #crystal-lang
olbat[m] has joined #crystal-lang
return0e has joined #crystal-lang
chemist69 has quit [Ping timeout: 250 seconds]
chemist69 has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 244 seconds]
ht_ has joined #crystal-lang
sorcus has quit [Ping timeout: 264 seconds]
ht_ has quit [Remote host closed the connection]
flaviodesousa has joined #crystal-lang
absolutejam has joined #crystal-lang
<FromGitter> <didactic-drunk> Is there a supported `memset` like function for `Bytes`? `#clear` doesn't seem to exist.
<FromGitter> <j8r> @Blacksmoke16 `User.from(JSON, data); user.serialize type`
<FromGitter> <j8r> more flexible
absolutejam has quit [Ping timeout: 244 seconds]
chemist69 has quit [Quit: WeeChat 2.3]
absolutejam has joined #crystal-lang
sorcus has joined #crystal-lang
<FromGitter> <confact> does anyone have an example of reading files and parse them? Tried to find tutorial or something in the reference but couldn't find it. I might have searched on wrong names though.
<FromGitter> <mavu> @confact If you are looking for a tutorial, you can probably search for one written in ruby, I think the File interface is practially identical.
<FromGitter> <confact> @mavu ah okay. I am a ruby developer and tried to find File in the reference document but couldn't. But then I will just test with some File.open and such.
<FromGitter> <confact> thnaks
<FromGitter> <mavu> the File api for crystal is here: https://crystal-lang.org/api/0.30.1/File.html
<FromGitter> <confact> @mavu Ah! that was what I was looking for. Thanks a lot!
<FromGitter> <mavu> You're welcome
absolutejam has quit [Ping timeout: 245 seconds]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 244 seconds]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> @j8r isnt that pretty much the same as `user.serialize :json`?
<FromGitter> <Blacksmoke16> but i guess its removing the enum in order to pass the module to use
<FromGitter> <j8r> @Blacksmoke16 No, because it's an enum. Passing a type will is more flexible
<FromGitter> <j8r> the type doesn't have to be in an enum
absolutejam has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
alex``` has quit [Quit: WeeChat 2.5]
chemist69 has joined #crystal-lang
<FromGitter> <naqvis> @didactic-drunk you can use `#to_unsafe.clear(count)` to reset `Slice`.
<FromGitter> <Blacksmoke16> @j8r true true, and i suppose if you pass some random module it wouldnt compile since there wouldnt be the correct method on it
absolutejam has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> i could go with that as well
<FromGitter> <sam0x17> is there a literal notation for something like this? ⏎ ⏎ ```Hash(Int64, Tuple(Int32, Int32)).new``` [https://gitter.im/crystal-lang/crystal?at=5d6e6c2bb4d8294074c42a7d]
<FromGitter> <sam0x17> (with values, not just a blank one)
<FromGitter> <Blacksmoke16> `{1_i64 => {1, 2}}`
<FromGitter> <Blacksmoke16> prob something like that
<FromGitter> <sam0x17> I'll try ty
<FromGitter> <tenebrousedge> looks like a good use for an alias
<FromGitter> <sam0x17> (yes, also that @tenebrousedge xD)
absolutejam has joined #crystal-lang
<FromGitter> <j8r> @Blacksmoke16 have you taken inspiration from https://gist.github.com/j8r/7d8395b1c37977ebcf568ea28cd08167?
<FromGitter> <Blacksmoke16> partially, at this point about 3 diff libs haha
<FromGitter> <Blacksmoke16> taking some points i like from each
<FromGitter> <Blacksmoke16> the major diff will be each "serializer" will just build its output string via an array of structs, vs going off of the actual object
<FromGitter> <Blacksmoke16> this way it would be like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d6e718e418f705d8786fd74]
<FromGitter> <Blacksmoke16> i.e. the common options can be shared vs needing `YAML::Field`, and `JSON::Field` with the same initial configuration duplicated for each format
<FromGitter> <Blacksmoke16> ill share something later on this week once i get something showable
<FromGitter> <j8r> 💯 with you
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <j8r> One time I wanted to do it, but I was on other topics :/
<FromGitter> <Blacksmoke16> ill keep you posted
absolutejam has quit [Ping timeout: 264 seconds]
absolutejam has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <j8r> anyone here interested of using Drone CI for a Crystal project?
absolutejam has quit [Ping timeout: 245 seconds]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 246 seconds]
ht_ has joined #crystal-lang
<FromGitter> <j8r> Would you create an organization? I suppose it will become a Serialization framework, like Serde
<FromGitter> <Blacksmoke16> possibly once it gets mature enough
duane has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> will it be a mono repo, or one repo per format?
<FromGitter> <j8r> maybe one for the stdlib, and then separate repos for said TOML, CON, whatever
<FromGitter> <Blacksmoke16> im not sure yet, havent thought that far ahead
<FromGitter> <Blacksmoke16> plan is to get a prototype to kinda show off what im thinking would be most ideal then go from there
<FromGitter> <j8r> that's a good start
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 245 seconds]
<FromGitter> <nsuchy> @j8r I prefer GitLab CI tbh
alex`` has joined #crystal-lang
<FromGitter> <Blacksmoke16> indeed, should be pretty slick
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <j8r> @nsuchy GitLab CI only works on GitLab, no?
_whitelogger has joined #crystal-lang
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
duane has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> @j8r https://play.crystal-lang.org/#/r/7h7c something like this is what i was thinking
absolutejam has joined #crystal-lang
<FromGitter> <Blacksmoke16> would also be some `Context` class that is optional to `#serialize` that would be used for runtime values, like groups/versioning etc
<alex``> how to set the type of "observers"
<alex``> in module Observable
<alex``> getter observers : [] of Observer
<alex``> but got a syntax error
<alex``> (Observer is an abstract class)
<FromGitter> <watzon> alex: what's the error?
<alex``> unexpected token
<alex``> observer.cr:6:22: error:expecting token 'CONST', not '[]'
<FromGitter> <watzon> Ohhh I see what you're doing
<FromGitter> <watzon> `getter observers = [] of Observer`
<FromGitter> <watzon> That's what you need
<alex``> oh
<FromGitter> <watzon> Or if you want to type it as well
<FromGitter> <watzon> `getter observers : Array(Observer) = [] of Observer`
<alex``> btw will it work using implemented class?
<alex``> class Foo < Observer
<alex``> Can I put foo in observers?
<FromGitter> <watzon> Yeah that's the whole point of abstract classes tbh
<FromGitter> <watzon> Any correctly extended abstract class will be allowed in the observers array
<FromGitter> <didactic-drunk> @watzon @Blacksmoke16 would it trouble either of you to agree on a compatible list of severity names so applications can port between your logging shards? emerg (https://github.com/hydecr/strange/blob/92a1397575e33b60ab899c12d83f2866af1a3352/src/strange/formatter/color_formatter.cr#L34) vs emergency (https://github.com/Blacksmoke16/crylog/blob/ee97471bb247a1b415d38ec24c0e4eb771ff40cd/src/logger.cr#L35)
<FromGitter> <Blacksmoke16> should be emergency imo
<FromGitter> <Blacksmoke16> is what it is in the rfc
<FromGitter> <Blacksmoke16> for syslog at least
<FromGitter> <didactic-drunk> "Informational" is also in the RFC. I'm not taking sides only pointing out that common use in many loggers shorten the names. warn vs warning is also common.
<FromGitter> <didactic-drunk> "warn" is what crystal uses.
<FromGitter> <Blacksmoke16> true
<FromGitter> <didactic-drunk> I'm making a PR with whatever you decide as a proposal for crystal's logger. I suspect @asterite, @jhass or @straight-shoota also have opinions.
<alex``> I don’t understand why Observable take (T)
<alex``> include Observable(Observer)
<alex``> it doesn't work without?
<alex``> what is the purpose of passing param
<alex``> is `module Observable(T)`, `T` a reference for `@observers ||= [] of T` L13?
<FromGitter> <Blacksmoke16> its a generic module yes
<alex``> ouki
<alex``> shouldn't be
<alex``> `def add_observer(observer : T)` then?
<alex``> instead of passing `Observer`?
<alex``> then
<alex``> ?
<FromGitter> <Blacksmoke16> i would think so?
<alex``> ouki
<alex``> If I get it right, without passing param to `include ModuleName`, we have to put an hard reference to the type, and with a param, it makes a reference to a type, generic
<alex``> L13 and 14
<FromGitter> <watzon> Yeah almost any container type should have a generic data type, `Observable(T)` is right
<alex``> isn't better to initialize in getter?
<alex``> getter observers = [] of T
<FromGitter> <watzon> @didactic-drunk I'm with you on the shorter names, it's why I have things the way they are
<alex``> instead of
<FromGitter> <j8r> @Blacksmoke16 not sure about `Array(Metadata)`
<alex``> `@observers ||= [] of T`
<FromGitter> <watzon> alex: not necessarily
<alex``> what is the benefices to add this code in add_observer?
<FromGitter> <Blacksmoke16> @j8r what about it?
<FromGitter> <j8r> Why array specifically?
<FromGitter> <Blacksmoke16> is possible some properties would be excluded, thus needed to be removed from the array
<FromGitter> <Blacksmoke16> i suppose you could use a tuple, but would have to create a new one with those removed since you cant directly edit it
<FromGitter> <Blacksmoke16> er you cant dynamically create a tuple so it has to be an array
<FromGitter> <j8r> I think this array can be avoided
<FromGitter> <Blacksmoke16> what would you propose instead?
<FromGitter> <j8r> using a block
<FromGitter> <j8r> I kinda like the idea of `Metadata`, that's a proper interface
<FromGitter> <Blacksmoke16> how would the block work?
<FromGitter> <Blacksmoke16> yea exactly, are uncoupling the object and the data that needs serialized
<FromGitter> <j8r> We have to look how Serde do, too
<FromGitter> <j8r> You don't like annotations anymore 😄 ?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <Blacksmoke16> that examples implements two
<FromGitter> <j8r> I mean. why not doing how `Serializable` does?
Groogy has joined #crystal-lang
<FromGitter> <Blacksmoke16> it does https://play.crystal-lang.org/#/r/7h7o
<FromGitter> <j8r> but `Serializable` use kwargs
<FromGitter> <j8r> (instead of Array)
<FromGitter> <Blacksmoke16> id be open to like `@[Name(serialized: "years_since_birth")]`
<FromGitter> <Blacksmoke16> or something like that, with another named arg for deserialized
<FromGitter> <Blacksmoke16> but you lost me on how this relates to replacing the array
Groogy has quit [Client Quit]
<FromGitter> <j8r> your example isn't complete, that's why it feels a bit flawed
Groogy has joined #crystal-lang
<FromGitter> <j8r> if all all objects implement `serialize`
<FromGitter> <j8r> We could have a more flexible implementation
<FromGitter> <Blacksmoke16> ill send you a more complete example later this week
<FromGitter> <Blacksmoke16> but thats the idea of why its defined on `Object`
<FromGitter> <j8r> for instance `puts "a".serialize JSON` doesn't work
<FromGitter> <j8r> why not doing like in https://gist.github.com/j8r/7d8395b1c37977ebcf568ea28cd08167 ?
<FromGitter> <Blacksmoke16> for types like that it would work like `.to_json` currently does im thinking
<FromGitter> <Blacksmoke16> but again, its a bit early :p
<FromGitter> <j8r> what was the issue with my implem?
<FromGitter> <Blacksmoke16> nothing in particular
<FromGitter> <Blacksmoke16> just messing around with some new ideas
<FromGitter> <HCLarsen> Hey guys, I just got a Invalid memory access (signal 11) at address 0x4 error when running my code. Is that a compiler issue, or is there a mistake in my code?
<FromGitter> <Blacksmoke16> prob the former
<FromGitter> <HCLarsen> Damn.
<FromGitter> <Blacksmoke16> able to reproduce it in https://play.crystal-lang.org/#/cr
<FromGitter> <Blacksmoke16> ?
<FromGitter> <HCLarsen> Thing is, this is a huge library I'm making. I'm not sure exactly what's causing it.
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> not working with unsafe stuff are you?
<FromGitter> <Blacksmoke16> if not then yea, best bet would be to see if you can reduce it
<FromGitter> <Blacksmoke16> and then see if an issue already exists or make a new one with the code
<FromGitter> <HCLarsen> What exactly is unsafe stuff?
<FromGitter> <Blacksmoke16> like working with pointers and stuff
<FromGitter> <Blacksmoke16> with pointers directly*
<FromGitter> <Blacksmoke16> yea that
<FromGitter> <HCLarsen> Nope, not doing any of that.
<FromGitter> <j8r> @Blacksmoke16 👌
<FromGitter> <Blacksmoke16> mainly wanted to play with having some way to define custom annotations that could be used
<FromGitter> <Blacksmoke16> as a way to exclude some properties at runtime
<FromGitter> <Blacksmoke16> as well as more flexibility over what/how each property gets serialized
ht_ has quit [Quit: ht_]
<FromGitter> <ezrast_gitlab> @HCLarsen Most of my segfaults come from leaning on the type system too hard, particularly mixing generic types and inheritance which is known to be broken.
<FromGitter> <tenebrousedge> @HCLarsen can you isolate it to a recent change? git bisect maybe?
<FromGitter> <Blacksmoke16> or just comment stuff out/delete stuff till it goes away, then slowly undo :p
<FromGitter> <Blacksmoke16> to get a minimal example
<FromGitter> <HCLarsen> @ezrast_gitlab not doing any generic types with this code. I'm working on the code that I changed when this started, just trying to nail down exactly where/what happened to cause it.
<FromGitter> <HCLarsen> I'm trying to use puts statements to determine exactly where the segfault is happening.
<FromGitter> <tenebrousedge> is it segfaulting at runtime or compile time?
coderobe has quit [Read error: Connection reset by peer]
DeBot has quit [Quit: Crystal IRC]
asterite has quit [Quit: Bye]
jhass has quit [Quit: Bye]
coderobe has joined #crystal-lang
<FromGitter> <HCLarsen> @tenebrousedge runtime.
<FromGitter> <watzon> @HCLarsen I got that very recently
<FromGitter> <watzon> Huge pain in the ass to figure out
<FromGitter> <watzon> In my case I'm pretty sure it was actually a compiler bug though
<FromGitter> <HCLarsen> @watzon did you create an issue on Github for it?
<FromGitter> <watzon> Not yet, I need to make a small reproducable sample
<FromGitter> <watzon> I'm working on it
<FromGitter> <HCLarsen> Ok. I'm also trying to isolate what's causing it for me.
<FromGitter> <watzon> In my case it was basically this: ⏎ The compiler allowed me to put procs with the signature `Proc(Foo, Foo)` into an array with the signature `Array(Proc(Foo, Nil))`. Then when I called the procs the runtime thew a fit because the output wasn't the expected `Nil`.
<FromGitter> <HCLarsen> Oh. I'm using Procs as well. Maybe I'll narrow my search to that.
<FromGitter> <watzon> Could be a problem
<FromGitter> <Blacksmoke16> also be aware of that
<FromGitter> <watzon> Hmm interesting
<FromGitter> <HCLarsen> Thanks @Blacksmoke16 , but I don't think that's my issue. All my procs are `Proc(String, Hash(String, String), String)`
<FromGitter> <Blacksmoke16> yea prob not, just be aware of it
<FromGitter> <Blacksmoke16> if you're working with procs
<FromGitter> <watzon> Yeah if you're storing them in an array and one of them happens to be returning the wrong thing it could be the issue
<FromGitter> <watzon> I'm working on a reproducable example right now
<FromGitter> <watzon> In my case I was also using annotations
<FromGitter> <HCLarsen> Now I've really messed up because I can't even recreate the issue.
<FromGitter> <watzon> Lol I'm having trouble creating a reproducable example as well
<FromGitter> <HCLarsen> I've actually stopped getting the error in my original code. Now I'm getting failing tests that passed before.
<FromGitter> <HCLarsen> I'm very confused.
return0e has joined #crystal-lang
<FromGitter> <HCLarsen> If I run each test on its own, it passes, but if I run the entire test file, I get between 3 and 5 failing tests.
<FromGitter> <watzon> It would seem that the tests are interfering with each other then?
return0e_ has quit [Ping timeout: 245 seconds]
<FromGitter> <watzon> This is pretty much exactly what I had before. No idea why it isn't working now. https://carc.in/#/r/7h8h
<FromGitter> <HCLarsen> Thing is, they weren't interfering with each other before I made a change to code that isn't even failing its tests.
<FromGitter> <watzon> As you can see though, the proc that's getting inserted into the array is the wrong signature
<FromGitter> <HCLarsen> Yup.
asterite has joined #crystal-lang
DeBot has joined #crystal-lang
jhass has joined #crystal-lang
<FromGitter> <HCLarsen> I figured out why my tests were failing, but now I'm not getting that segfault.
<FromGitter> <watzon> Hmm weird. I gave up on trying to reproduce what I was getting before.
DeBot has quit [Quit: Crystal IRC]
asterite has quit [Quit: Bye]
jhass has quit [Quit: Bye]
DeBot has joined #crystal-lang
asterite has joined #crystal-lang
<FromGitter> <HCLarsen> Yeah, I'm officially stumped. But at least all my tests are running.
jhass has joined #crystal-lang
return0e_ has joined #crystal-lang
absolutejam has quit [Ping timeout: 244 seconds]
return0e has quit [Ping timeout: 246 seconds]
absolutejam has joined #crystal-lang
Nekka_ has joined #crystal-lang
absolutejam1 has joined #crystal-lang
Nekka has quit [Ping timeout: 258 seconds]
Nekka_ is now known as Nekka
absolutejam has quit [Ping timeout: 258 seconds]
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 244 seconds]