ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<lunarkitty> Hey, with a class with a member var type set, how can I get away with leaving things nil?
<lunarkitty> I am getting things like `Error: can't restrict nil to TYPEXYZ`
<FromGitter> <Daniel-Worrall> Can you post an example? I feel like I understand but not quite
<FromGitter> <Blacksmoke16> `token : Token?`
<FromGitter> <Blacksmoke16> `?` is a shortcut to `Token | Nil`
<lunarkitty> oh ty!
<lunarkitty> ooooh I see union types
<FromGitter> <Blacksmoke16> yup
<FromGitter> <Blacksmoke16> also protip
<FromGitter> <Blacksmoke16> `def initialize(@token : Token? = nil, @type : Symbol? = nil); end`
<lunarkitty> Yes ty! Very cool
DTZUZU has quit [Quit: WeeChat 2.8]
<lunarkitty> kinda like a member initializer list
<FromGitter> <Blacksmoke16> it does the ivar definition and assignment in one step
<FromGitter> <Blacksmoke16> versus needing the temp local var to assign to the ivar
<lunarkitty> nice
<lunarkitty> hey, kinda off topic but I'm curious, what was the original language crystal was written in before the compiler was written in crystal?
<FromGitter> <Blacksmoke16> ruby
<lunarkitty> that makes sense
<FromGitter> <Blacksmoke16> https://github.com/asterite/crystal
<lunarkitty> oh wow, very interesting
* FromGitter * Blacksmoke16 hopes it doesn't change again to `2020-06-10` tomorrow :P
renich has joined #crystal-lang
renich_ has joined #crystal-lang
renich has quit [Ping timeout: 260 seconds]
renich_ is now known as renich
renich_ has joined #crystal-lang
renich has quit [Ping timeout: 260 seconds]
renich_ is now known as renich
renich has quit [Quit: renich]
chachasmooth has quit [Ping timeout: 260 seconds]
chachasmooth has joined #crystal-lang
DTZUZU has joined #crystal-lang
_ht has joined #crystal-lang
mistergibson has joined #crystal-lang
<raz> mmm libxml
<raz> soon we'll need a bundler-audit for crystal
<raz> shardler-audit
<FromGitter> <naqvis> libxml isn't that part of stdlib
<raz> i'm sure that will be fixed after the 6th CVE or so :P
<FromGitter> <naqvis> :D
<FromGitter> <naqvis> are there any breaking changes in latest version of libxml?
alexherbo2 has joined #crystal-lang
<raz> no idea. i only remember it because nokogiri pops up in bundler-audit every now and then. but looking at the history it doesn't actually seem that bad (1 in 2020, 3 in 2019)
alexherbo2 has quit [Remote host closed the connection]
<FromGitter> <naqvis> should be really good
<FromGitter> <naqvis> i remember last time (due to some forum thread) there was a discussion on scanning the docker images of Crystal, there were many CVE
<FromGitter> <naqvis> for that were all due to base images
<FromGitter> <naqvis> alpine based images seems quite great wrt to CVE
<raz> yea i think in the long term it would be nice to have CVE checks baked directly into the shards-utilit
<raz> or perhaps integrate with the github/gitlab security checks
<raz> but haven't thought about it much yet
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 i just read an entire github about the placement of an io named argument
deavmi has quit [Ping timeout: 260 seconds]
deavmi has joined #crystal-lang
<raz> all of github? like back-to-back? :D
zorp_ has joined #crystal-lang
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter> <neutrinog> hey, I'm porting a constraint solving algorithm (for calculate GUI constraints) and I've been moving all of the operations into handy dandy methods like `def ==(...` so I can easily specify constraints like `x == y + 10`. Pretty straight forward and works great. However... I'm running into a problem when my constraint equation looks like this `(x + 10) == 20`. The compiler thinks it's a boolean. If however I
<FromGitter> ... have a constraint equation with a variable on either side everything works fine `x + 2 == y + 10`.
<FromGitter> <neutrinog> I have a specific test that's failing here https://github.com/neutrinog/kiwi-crystal/blob/master/spec/kiwi_spec.cr#L7-L10
<FromGitter> <Blacksmoke16> prob related to your overloads?
<FromGitter> <Blacksmoke16> where is the def of `==`?
<FromGitter> <neutrinog> primarily in the Expression https://github.com/neutrinog/kiwi-crystal/blob/master/src/expression.cr
<FromGitter> <neutrinog> actually, only in the expression.
<FromGitter> <Blacksmoke16> well to be clear, are those overloads even working since you're just using Int32s
<FromGitter> <Blacksmoke16> nvm i see `x` now
<FromGitter> <neutrinog> hm.. actually that was it. I made the `20` on the rhs 20x64 and it works now.
<FromGitter> <Blacksmoke16> but im still surprised it works,
<FromGitter> <neutrinog> previously the compiler was able to figure out the types automatically.
<FromGitter> <Blacksmoke16> `def +(other : Expression)` which is like `x.+(2)` which 2 is not an `Expression`
<FromGitter> <Blacksmoke16> so dont think it was using that overload
<FromGitter> <neutrinog> there are additional operators defined in other classe.s
<FromGitter> <Blacksmoke16> ah 👍
<FromGitter> <neutrinog> `variable + 2` becomes `term + 2` which becomes `expression + 2`
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <neutrinog> I think my solution will be to change the float operator arguments to `Number` and then simply `to_f64` it in the constructor. Is there any reason why I shouldn't use `number.to_f64` blindly like that?
<FromGitter> <neutrinog> I just like the option to not have to affix `f64` to all my numbers.
<FromGitter> <Blacksmoke16> prob would be fine
<FromGitter> <Blacksmoke16> assuming the numbers wont be big enough to lose precision?
<FromGitter> <neutrinog> I think f64 will be as large as anyone will need.
<FromGitter> <neutrinog> This is only for UI constraint calculations.
<FromGitter> <Blacksmoke16> 👍
mistergibson has quit [Quit: Leaving]
<FromGitter> <neutrinog> so now that I'm overriding all of the `==` methods I can't perform regular object comparison. Is there a way to do object comparison without using `==`?
<FromGitter> <neutrinog> Externally, I want to use `==` because it's convenient for writing constraints. Internally (in the constraint algorithm) I want to be able to do regular object comparison (is that object this object).
<FromGitter> <neutrinog> it would be ok if I had to write some black magic and use a custom `.equals` method for internal use.
<jhass> mmh, I don't think we really have alias/alias_method
<jhass> what kind of objects are you defining == for?
<jhass> and what does regular object comparision actually mean for them?
<jhass> (sorry, I dind't read up on all the above)
<FromGitter> <neutrinog> it's a constraint algorithm. Here's a mini example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5edf8d4024a3382d5d56d539]
<FromGitter> <neutrinog> the `==` produces the constraint.
<jhass> the two major == definitions in stdlib are Reference#== https://github.com/crystal-lang/crystal/blob/master/src/reference.cr#L17
<jhass> as you can see for Reference types, if you want that default implementation, you can just call same?
<jhass> for struct it's a bit more complex
<jhass> but maybe equality is domain specific for your objects anyhow?
<jhass> so just define your own method for internal use
<FromGitter> <neutrinog> externally yes, but internally the algorithm treats them as regular objects in a hash and needs to perform regular object comparison.
<FromGitter> <neutrinog> `same?` should be exactly what I need.
<jhass> mmh, yeah putting them in hash and overriding == seems dangerous
<FromGitter> <neutrinog> Though I'm probably going to migrate everything to structs eventually.
<jhass> maybe you should have a DSL object and an internal version?
<jhass> the DSL version could be a simple struct wrapper around the internal one
<jhass> and for storage you fetch the internal one from the wrapper
<FromGitter> <neutrinog> That would probably be a bit safer to maintain.
<FromGitter> <neutrinog> actually, the algorithm needs to keep track of these particular objects anyway so it can update the values. So I'll need to at least store them in an array and map the index to some key.
<FromGitter> <neutrinog> using `same?` might actually be less ugly. And the worst that could happen is the compile will scream at me if I accidently use == internally.
<jhass> still might make sense to decouple the state from the DSL? struct Expression; @state = ExpressionState.new; def ==(other); @state.restrict_equals(other.@state); end; end; Idk, probably the particular example doesn't quite capture what you're doing but it illustrates the concept of a wrapper that provides the pretty API but delegates any state changes to some internal object which you can
<jhass> then fetch, store and reconstruct a DSL wrapper around as needed
<FromGitter> <neutrinog> yeah that makes sense.
<FromGitter> <neutrinog> initially all of the operators were decoupled as global methods (from the java source).
<travis-ci> crystal-lang/crystal#ce1b36c (master - Update distribution-scripts (#9446)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/696459107
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9446 (Update distribution-scripts)
duane has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#3c48f31 (master - Release 0.35.0 (#9317)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/696486862
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<FromGitter> <Blacksmoke16> 👏
<FromGitter> <naqvis> hurray
<FromGitter> <naqvis> 👏
<FromGitter> <naqvis> but `brew` formula update might take some time to reflect
<FromGitter> <Blacksmoke16> docker/snap is fast so not so bad for me :p
<FromGitter> <naqvis> lol
* FromGitter * Blacksmoke16 been using nightly version for weeks :S
<FromGitter> <Blacksmoke16> `sudo snap install crystal --classic --edge`
<FromGitter> <Blacksmoke16> uses nightly release
<FromGitter> <Blacksmoke16> quite handy
<FromGitter> <naqvis> 👍
<FromGitter> <naqvis> prior to https://github.com/crystal-lang/crystal/pull/9126, this restrictions was quite frustrating for me, as I had to made open many internal enums
<FromGitter> <Blacksmoke16> some exciting stuff in this release thats for sure
<FromGitter> <naqvis> true
<FromGitter> <naqvis> also quite a bunch of *breaking changes*
<FromGitter> <Blacksmoke16> most are deprecations so not terrible
<FromGitter> <naqvis> I just counted and you made 9 PR into this release. Hats off and Bravo to you @Blacksmoke16 👍 👍 👍
<FromGitter> <Blacksmoke16> 😎 thanks ha
<FromGitter> <Blacksmoke16> #9120 is the big one
<DeBot> https://github.com/crystal-lang/crystal/pull/9120 (Add .each and .each_with_index to various macro types)
<FromGitter> <Blacksmoke16> that im the most excited about
<FromGitter> <naqvis> yeah true
<FromGitter> <naqvis> I had this impression that https://github.com/crystal-lang/crystal/pull/9091 was included in this release, but just checked, its still open
<FromGitter> <Blacksmoke16> expect some new Athena versions soon 😉
<FromGitter> <naqvis> woha 👍
<FromGitter> <Blacksmoke16> its in a holding pattern until after `1.0.0` apparently
<FromGitter> <Blacksmoke16> as *most* of what it enables is doable with current syntax, just with more duplication
<FromGitter> <Blacksmoke16> the other stuff needs a design phase
<FromGitter> <Blacksmoke16> so we'll see
<FromGitter> <naqvis> yeah true and your intention in that PR was to enable DRY
<FromGitter> <Blacksmoke16> also ended up allowing some things *not* currently possible with macros, like recursion
<FromGitter> <naqvis> awsome 👍
<FromGitter> <Blacksmoke16> also allowed something like:
<FromGitter> <Blacksmoke16> cut down version
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5edfa8ee1e099b0388b66a85]
<FromGitter> <Blacksmoke16> i.e. allow mutating a hash of data at compile time that could be later used to do whatever
<FromGitter> <Blacksmoke16> if that's something that is actually wanted is still TBD, hence why that PR is in limbo ha
<FromGitter> <naqvis> that's neat
<FromGitter> <naqvis> i'm just thinking what if i misspell or don't add `compile` macro, will I get compile-time error?
<FromGitter> <Blacksmoke16> related to the serialization stuff we been talking about, i think it could also be used as a way for users to define custom exclusion logic of their ivars
<FromGitter> <naqvis> though i include `CompilerPass`, but don't provide `compile` macro, what would happen?
<FromGitter> <naqvis> yeah, true. and Its really very neat
<FromGitter> <Blacksmoke16> if its not handled by default, id deff add some custom validation to raise if its not right; like not a module and/or doesnt have that method
<FromGitter> <naqvis> gotcha 👍
<FromGitter> <Blacksmoke16> yup, be a better way to handle *most* custom annotation exclusion stuff
renich has joined #crystal-lang
renich has quit [Client Quit]
renich has joined #crystal-lang
renich has quit [Ping timeout: 256 seconds]
renich has joined #crystal-lang
<FromGitter> <lbarasti> Hi folks, trying something new, premiering a live-coding session on building a DSL interpreter in Crystal now: https://www.youtube.com/watch?v=C8R5GYJ9KYo
<FromGitter> <naqvis> 👍
<FromGitter> <ImAHopelessDev_gitlab> @lbarasti nice :D
renich has quit [Quit: renich]
renich has joined #crystal-lang
<FromGitter> <vlazar> ❤️
<raz> awesome
bcardiff has joined #crystal-lang
ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.35.0 | 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
lvmbdv has quit [Quit: bye]
bcardiff has quit [Quit: bcardiff]
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e683b9e (ci/update - Update CI to use 0.35.0): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/696594755
travis-ci has left #crystal-lang [#crystal-lang]
<oprypin> cc @j8r (was it?)
krobin has joined #crystal-lang
<raz> why does ci use 0.35 but version says 1.0?
<FromGitter> <Blacksmoke16> its `-dev` version no?
_ht has quit [Remote host closed the connection]
ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.0 | Fund Crystal's development: https://crystal-lang.org/sponsors/ | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | Gitter: https://gitter.im/crystal-lang/crystal
ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.0 | 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
HumanGeek has joined #crystal-lang
<sorcus> Mmm, new release contains a lot of `breaking-changes`.
Human_G33k has quit [Ping timeout: 258 seconds]
<sorcus> Thanks everyone who does Crystal better. :-)
zorp_ has quit [Ping timeout: 260 seconds]
chachasmooth_ has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
chachasmooth has quit [Ping timeout: 260 seconds]
<raz> move fast and break things! :)