ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.0 | Fund Crystal's development: | Paste > 3 lines of text to | GH: | Docs: | API: | Logs:
_whitelogger has joined #crystal-lang
Stew is now known as Guest75230
DETZUZU has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
Guest75230 has quit [Ping timeout: 260 seconds]
bmcginty has quit [Ping timeout: 260 seconds]
bmcginty has joined #crystal-lang
<FromGitter> <jsilverMDX> has anyone seen this
<FromGitter> <jsilverMDX> ```code paste, see link``` []
<FromGitter> <azzuwan> How can I inspect what modules is using a lot of memory in a running crystal process?
<FromGitter> <renich> Guys, how can I do this?
<FromGitter> <renich> Damn, found an ugly hack:
<FromGitter> <renich> Is there a better way?
_whitelogger has joined #crystal-lang
jamie_ca has quit [Quit: ZNC -]
<FromGitter> <renich> OK, I understand why x = 10 * 10000000000 is giving me some odd number. I don't understand why x = Int64; x = 10 * 10000000000 is not working...
<FromGitter> <jsilverMDX> isnt it x : Int64
<FromGitter> <renich> Jon: that word.... up until 99,999,999,999,999,999,999
<FromGitter> <renich> 99 quintillion
<FromGitter> <renich> or something
<FromGitter> <renich> Ok, but: `10 * 10000000000 / 9.243` doesn't work... :S.
<FromGitter> <renich> Or, rather, something more predictable: `x = 10 * 100000000000 / 2.0; puts x` ⏎ `
<FromGitter> <renich> This gives me -363689984.0
<FromGitter> <jsilverMDX> no idea. sorry
<FromGitter> <renich> No worries.
<FromGitter> <renich> Not even BigInt can do: `1000000000000000000000000000 / 2.0`.
<FromGitter> <renich> and there is no big float... let me check again
_whitelogger_ has joined #crystal-lang
_whitelogger has quit [Remote host closed the connection]
DETZUZU has quit [Quit: WeeChat 1.9]
<FromGitter> <johnjansen> @renich ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <renich> @johnjansen o/. thanks.
<FromGitter> <johnjansen> apples with apples … having said that i understand the WTFness to some degree
<FromGitter> <johnjansen> that was meant to be `require “big_float”` although mysteriously the above works
<FromGitter> <johnjansen> and thats because `require “big”` is all you need
[spoiler] has joined #crystal-lang
jaitaiwan_ has joined #crystal-lang
omninonsense has quit [Ping timeout: 240 seconds]
jaitaiwan has quit [Ping timeout: 240 seconds]
<FromGitter> <renich> @johnjansen thanks for the example. it is very useful.
<FromGitter> <renich> Maybe it's just me and my stupidity but I think the docs need to be revamped
<FromGitter> <renich> Is there a way to improve this?
<FromGitter> <oprypin> only with yaml mapping
<FromGitter> <johnjansen> haha … i was just whipping up a sample @oprypin
oz has quit [Ping timeout: 240 seconds]
oz has joined #crystal-lang
<FromGitter> <johnjansen> @renich
<FromGitter> <renich> @johnjansen wow! Cool, man! Thanks! Let me make sense of it.
<FromGitter> <renich> why lines 12 and 13?
<FromGitter> <renich> I mean, could we just live with line 13?
RX14 has quit [Ping timeout: 260 seconds]
<FromGitter> <johnjansen> 12) because adding a mapping adds a constructor which takes yaml pull parser, and having 1 initializer means you cant do `` anymore without meeting the requirements … ⏎ 13) for convenience given your example
<FromGitter> <johnjansen> if you comment out 12 you will see the issue
<FromGitter> <renich> ah, yes, overload according to method args... yes, I use that. Pretty cool.
lhz has quit [Ping timeout: 240 seconds]
lhz has joined #crystal-lang
RX14 has joined #crystal-lang
<FromGitter> <renich> Is there anything wrong with this?
<FromGitter> <renich> I find math to be much easier. Even Then there are all kinds of floats/ints involved
Dreamer3_ has joined #crystal-lang
Dreamer3 has quit [Ping timeout: 260 seconds]
<FromGitter> <johnjansen> why so many types? convenience?
hightower2 has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 276 seconds]
<FromGitter> ... JSON request is returned with keys starting with a capital letter.
<FromGitter> <coderhs> Hey How can i create a JSON.mapping for keys which are starting with a capital letter `{"Epc" => "000221153000000012500052", "Qty" => 1, "Upc" => "999999"}` when i do the following code `JSON.mapping(Epc: String, Qty: Int32, Upc: Int64)` i get error that it is expecting `)` not `:`. Also tried `JSON.mapping("Epc" => String, "Qty" => Int32, "Upc" => Int64)` works only if i place the key in smaller letter but my
<hightower2> coderhs: I would say that you use a lowercase letter, but you do something like : myfield: { type: ..., key: "Qty" }
<hightower2> (See near the bottom of
<FromGitter> <coderhs> I too would love that but the response is out of my control :( ⏎ ⏎ Thanks for the reply let me try it.
<hightower2> coderhs: no I mean, in your program you define the field using a lowercase letter
<FromGitter> <coderhs> yes. definitely. Thank you for the help I got it to working.
hightower2 has quit [Ping timeout: 258 seconds]
<FromGitter> <sdogruyol> Good morning everyone :)
<Groogy> Morning!
<FromGitter> <sdogruyol> @Groogy how're you
<Groogy> tired, been up night trying to debug why my computer won't start after assembling it again :(
<Groogy> you then?
<FromGitter> <sdogruyol> sorry to hear that, hope you make it work soon :(
<FromGitter> <sdogruyol> I'm good, thank you
<FromGitter> <sdogruyol> working on an small but interesting project which implements all Github API routes and benchmarking
<FromGitter> <sdogruyol> currently it includes Kemal and Sinatra for comparison
<FromGitter> <crisward> @kazzkiq We're querying the google analytics api to get data from crystal.
mark_66 has joined #crystal-lang
<FromGitter> <codenoid> `` undefined constant Crypto::MD5 `` > Digest:: too :/
<FromGitter> <sdogruyol> @codenoid what?
<FromGitter> <crisward> @sdogruyol One of my clients is getting a 500 error. I have a logged error but it doesn't reference any of my code. Any ideas? ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <crisward> I'd raise an issue against kemal, but I'm not sure it's that. I'm using crystal 0.22.0.
tzekid has joined #crystal-lang
<FromGitter> <krypton97> jesus
<FromGitter> <codenoid> @sdogruyol i want use MD5 function in kemal
<FromGitter> <codenoid> `` Crypto::MD5.hex_digest("cat") ``
<FromGitter> <crisward> `OpenSSL::MD5.hash("blah").to_slice.hexstring`
<FromGitter> <crisward> will output an md5 hash as a hexstring
<FromGitter> <crisward> obviously change "blah" to what you're trying to hash
<FromGitter> <crisward> It works, not sure it's the most elegant way. Not reached crystal guru status yet
hightower2 has joined #crystal-lang
<FromGitter> <codenoid> thanks cris,
fenicks has joined #crystal-lang
fenicks has left #crystal-lang [#crystal-lang]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<hightower2> Merhaba sdogruyol :)
<FromGitter> <codenoid> i think it just warning @crisward , but i dont like that warning
<FromGitter> <codenoid> somebody say ws client has been closed,
<FromGitter> <renich> I've discovered a bug in
<FromGitter> <codenoid> ups, xD i read crystal 0.20.1 when use 0.23.0 , ,
<FromGitter> <renich> If you try to use some = <<-'EOR', it dies
<FromGitter> <renich> Oh, and, btw, could you help me with this?
<FromGitter> <renich> I dunno why it doesn't work...
<FromGitter> <renich> been struggling for hours
<FromGitter> <renich> I don't know how to tell it that an Array of Objects starts there (line 3 of the json)
<FromGitter> <renich> OK, it's 4:23 AM here so I going to sleep. I appreciate any help on this one. Thanks!
<FromGitter> <crisward> Your floats are strings though...
<FromGitter> <crisward> And the last char of your json was an array `]` instead of `}` - this works -
<FromGitter> <crisward> @sdogruyol found the problem, the undying error is in the JSON parser, when you try and parse {} however it gets masked by another error. Suffice to say you can ignore this.
<FromGitter> <renich> @crisward dude, you rock!
<FromGitter> <renich> Now I can sleep nicely!
<FromGitter> <akzhan> 1) 23
<FromGitter> <bew> with a pointer on a struct, when I do `ptr.value` (to access or modify a field), will there be a copy of the struct?
<FromGitter> <bew> the question is for lib's kind of structs
bjz has joined #crystal-lang
<FromGitter> <krypton97> no need to do a pointer on a struct
<FromGitter> <krypton97> you should use stack memory as much as possible
<FromGitter> <krypton97> and no, if you pass by refference, there won't be any copy
<FromGitter> <krypton97> but structs are passed by value by default
<FromGitter> <codenoid> yass, my first crystal article
<FromGitter> <bew> @krypton97 I receive a struct pointer from a library call
<FromGitter> <krypton97> to answer you question "will there be a copy of the struct?", that's not how pointers work
<FromGitter> <akzhan> @bew ptr.value points to value itself
<FromGitter> <bew> yeah ok, perfect, thanks
<FromGitter> <bew> I think it's the special case of crystal's type system and accesses, do you know where `Pointer#value` and `Pointer#value=` are defined?
<FromGitter> <krypton97> read there
<FromGitter> <bew> yeah I know, but it's not here
<FromGitter> <bew> oh found it in primitives
<FromGitter> <bew> ah yes you too :p
<FromGitter> <krypton97> what binding are u trying to do??
<FromGitter> <bew> was just a test, to bind on XCB
<FromGitter> <bew> I stopped at point 7, it works well, will continue tonight (in 6-7 hours)
<FromGitter> <krypton97> nice
<FromGitter> <sdogruyol> @codenoid congrats :tada:
<FromGitter> <sdogruyol> @crisward thank you :)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <straight-shoota> @codenoid Why are you not writing to the final file path directly?
splitty_ has quit [Ping timeout: 276 seconds]
bjz has joined #crystal-lang
hightower2 has quit [Ping timeout: 258 seconds]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
Yxhuvud has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> @benoist How goes your inteliji IDE plugin project ?
<FromGitter> <ziprandom> @sdogruyol hey what exactly do you want to acomplish with kemal-github-api
<FromGitter> <ziprandom> ?
<FromGitter> <ziprandom> I've been wanting to setup an environment where I can test graphql-crystal against the go implementations using wrk ...
bjz has joined #crystal-lang
bew78 has joined #crystal-lang
bew78 has left #crystal-lang ["WeeChat 1.9"]
bjz_ has quit [Ping timeout: 260 seconds]
bjz_ has joined #crystal-lang
<FromGitter> <sdogruyol> @ziprandom create a real-world like routing benchmark
bjz has quit [Ping timeout: 248 seconds]
w-p has joined #crystal-lang
<w-p> anyone here? i'm looking for current guidance on the use of globals.
<w-p> the docs seem to contradict the compiler and github issues.
<Groogy> think globals were removed?
<Papierkorb> w-p: Real globals have been removed and are gone for good
<w-p> should prolly be axed.
<Papierkorb> Good point
<w-p> i try to rtfm before asking.. :)
<FromGitter> <sdogruyol> Yeah it should be removed
<FromGitter> <sdogruyol> @w-p that's great :)
<w-p> that said, the compiler asks you to use @@class_variables. does that make sense in the context of, for example, a kemal server with a few simple routes?
<Papierkorb> w-p: If there is a possibility to not use globals, as there is most of the times, try to not use globals
<w-p> right. so, static classes.
<Papierkorb> Not using global-like variables doesn't really increase source code length, but improves maintainability considerably
<Papierkorb> Static classes are globals
<w-p> no argument from me.
<FromGitter> <ziprandom> @sdogruyol ah ok, so you don't need any real logic. but you don't intend to run it against the real api for comparison (because it's not opensource i guess)
<Papierkorb> If you really need a shared state, make that shared-state class a normal class, but store a reference to it somewhere. If needed, a global one (=> Singleton)
<w-p> more like a configuration object pattern.
<Papierkorb> Oh it's for immutable configuration?
<w-p> in this case, yes.
<w-p> runtime server configuration. similar to a Flask config dict / obj.
<Papierkorb> In that case, it's acceptable. If you can, have no setters in there. YAML.mapping() supports this and you can easily read config with it too
<w-p> oh cool. good call.
<FromGitter> <sdogruyol> @ziprandom yep
splitty_ has joined #crystal-lang
mark_66 has left #crystal-lang ["PART #elixir-lang :PART #ruby :PING 1499349104"]
<FromGitter> <eliasjpr> Hello everyone, just wanted to let everyone know that the Amber team has added support for Crystal v0.23.0 for those who already have the `amber cmd` just run a `brew update` on mac, for new installs `brew install amber-crystal/amber/amber`
<FromGitter> <sdogruyol> @eliasjpr congrats :)
<FromGitter> <sdogruyol> Keep up the good work
<FromGitter> <eliasjpr> Thanks!
<FromGitter> <mverzilli> great!
<FromGitter> <codenoid> @straight-shoota idk '-'
<FromGitter> <codenoid> i just make a simple blog, :satisfied:
hightower2 has joined #crystal-lang
j0hnny has joined #crystal-lang
<FromGitter> <bew> Is this normal?
<Groogy> type is more restrictive than alias from what I remember from documentation
<FromGitter> <bew> a `type` in a lib binding doesn't get all the constants of the typed type
<FromGitter> <bew> yeah I know that part, but I wouldn't expect this to fail
<FromGitter> <bew> it's quite annoying with this example:
<j0hnny> hello everyone! is there a way to install an older version of crystal on ubuntu? say 0.22.0 instead of 0.23.0?
<FromGitter> <bew> idk, but why would you want that?
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<j0hnny> 0.23.0 is breaking a few shards i'm using
<j0hnny> namely Crecto
<FromGitter> <fridgerator> yep crecto is broken in 0.23.0, haven't had a chance to address yet. I should be able to work on it tonight.
<FromGitter> <fridgerator> I have a macro method `schema`, that is now throwing compiler error undefined method
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> @fridgerator when compiling `src/` I only get an `undefined constant DB::Database` and adding `require "db"` on top of that file fixes the error
<FromGitter> <fridgerator> `crystal spec` is when I see the error, or when including it in another project
<FromGitter> <bew> ah yes I see it
<j0hnny> hello fridgerator! yes i'm the one who posted the issue yesterday
<j0hnny> thank you for looking at it!
<j0hnny> and for the excellent library
<FromGitter> <sdogruyol> yeah, thanks for crecto @fridgerator
splitty_ has quit [Ping timeout: 276 seconds]
unshadow has joined #crystal-lang
<FromGitter> <bew> @fridgerator I recreated the error with: (this code in 0.22 works, but not 0.23 (not available on yet))
Dreamer3_ has quit [Quit: Computer has gone to sleep.]
<FromGitter> <gabrielrios> I think its related to #4639 @bew
<DeBot> (Macro lookup from included module broken)
<FromGitter> <bew> oh right, thanks
<FromGitter> <codenoid> `Exception: Closed stream (IO::Error) `
<FromGitter> <codenoid> ```code paste, see link``` []
<FromGitter> <codenoid> is my local site
<FromGitter> <codenoid> top. crystal, bottom php
Yxhuvud has joined #crystal-lang
<FromGitter> <straight-shoota> @fridgerator 0.23.0 is broken, you should probably wait for 0.23.1 before fixing stuff that isn't necessarily wrong in crecto
<Papierkorb> pre-release, a CI could probably just run the unit tests of popular shards. If it fails, something is off.
<FromGitter> <molovo> That’s how NodeJS do it. It works really well for picking up unexpected bugs
<FromGitter> <molovo>
<Papierkorb> I mean it's not perfect, but besides setting up the script for it, comes almost for free
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <straight-shoota> I think nightly builds are even more valuable, because then people will use them (for new features and stuff) and detect errors
<FromGitter> <straight-shoota> Though, both would be nice^^
<FromGitter> <molovo> You can already get that on Mac by tracking master with `brew install —HEAD crystal-lang`. I believe `apt` supports something similiar too, but I can’t remember the command off the top of my head
<FromGitter> <fridgerator> thanks @straight-shoota , I just saw your issue referenced above
<FromGitter> <fridgerator> Is there already a 0.23.1 scheduled?
<FromGitter> <straight-shoota> should be coming soon I expect
<oprypin> fridgerator, core team said it is important to have 0.23.1 soon but no concrete date
<FromGitter> <mverzilli> hi! there's only one "behavior issue" for 0.23.1:
<FromGitter> <mverzilli> there's already a PR for that
<FromGitter> <mverzilli> we already fixed the key issues for apt
rohitpaulk has joined #crystal-lang
<FromGitter> <mverzilli> now we're working on getting 0.23 packages for Ubuntu 12 and 14
<FromGitter> <mverzilli> (related to the glibc/stdc++ issues)
<FromGitter> <mverzilli> we'll probably have to stick with LLVM3.5 just for Centos packages
<FromGitter> <mverzilli> no dates, but we'll probably release once we have Ubuntu 12 and 14 packages again
<FromGitter> <fridgerator> :thumbsup:
<Yxhuvud> mverzilli: Do you care about Centos that much? They do tend to have packages from the stone age, so if you limit yourself to them you are in for a world of pain in the long run.
<Yxhuvud> I wonder this after being stuck with ruby 1.8.7 for something like 4-5 years longer than the rest of the world.
j0hnny has quit [Quit: Page closed]
<FromGitter> <mverzilli> (on a call, will reply that in 5 minutes, sorry)
<Yxhuvud> no worries, I'm not in a rush.
unshadow has quit [Quit: leaving]
<Yxhuvud> hmm, I wonder why llvm hasn't provided binaries for redhat derivates since 3.9.
<FromGitter> <elorest> @bew about a year ago.
<FromGitter> <mverzilli> Yhuvud: there were reports of some people that was aiming to use Crystal on Centos for production, and we don't want to let them out. The middle ground we found is to just stick to LLVM3.5 for redhat derivatives, so that doesn't leave as anchored on the rest of the distros/platforms
<Papierkorb> Wasn't llvm3.5 super broken, as in release builds producing wrong SHA1 hashes and such?
<FromGitter> <mverzilli> that complicates a bit the release and leaves some code in the codebase that ideally we'd like to remove, but it's best tradeoff we can think of
<FromGitter> <mverzilli> Papierkorb, I'm not sure if "super broken", there were some issues that happened with LLVM3.5 and just went away since LLVM3.8
<oprypin> llvm3.5 really is super broken, there are random memory corruptions
<oprypin> in my world view centos is also totally broken but whatever
<FromGitter> <mverzilli> lol
<FromGitter> <mverzilli> the fact that we have some bugs with LLVM3.5 that stopped happening in LLVM3.8 doesn't mean LLVM3.5 is broken. It could be a problem on Crystal's side that we couldn't identify
<FromGitter> <mverzilli> so, what we want to do is, still publish packages for CentOS with LLVM3.5, to not let CentOS users out of the loop
<oprypin> what about those memory corruptions though
<FromGitter> <mverzilli> then I guess we would welcome PRs fixing a LLVM3.5 issues in Crystal
<FromGitter> <bew> are there similar LLVM3.5 issues in other LLVM-based languages?
<FromGitter> <mverzilli> not that we're aware of, but we didn't research that
<oprypin> maybe it's possible to bisect on llvm?
<oprypin> mmmm nope, building llvm is too cmplicated
<hightower2> I have a situation where I have 2 variables, both of which can be Nil | Int | Bool | Range. And I need to "compare" them (whatever my specific "comparison" may be between two types). Since this is in total 8 combinations (and possibly will grow), how do I best implement this comparison? Anything "better" than simply the main 'case' statement for var1 and then under each 'when' to put the the whole 'case' statement for var2?
<Yxhuvud> I think I'd try to figure out a way to get a better type signature in that case
<hightower2> Yxhuvud, there isn't any. I intentionally provide the user with the option to specify any of these types, for his convenience
<hightower2> (and I then work with these types because it suits my application to have e.g. a Range instead of "expanding" it into e.g. array)
<Papierkorb> hightower2: What kind of comparison? equal, or <, > ?
<oprypin> hightower2, could be `private def compare(a : Int | Range, b : Bool)`
<oprypin> then `private def compare(a, b); compare(b, a)` .. maybe?
<oprypin> uh `-compare`
<hightower2> Papierkorb, yes, basically my comparison between any of these types is "does A include B", where if number, it's a==b, if range, it's a.includes? b, if nil then true, if false then no.
<hightower2> but it's a bit more complicated since both a and b can have all listed types, including the comparison between range == range etc.
<hightower2> (which I consider true if one range is within other)
<oprypin> hightower2, im saying instead of series of `case` you define a series of methods and use dispatch
<hightower2> Oh pretty cool, yeah I could use overloading here
<hightower2> Coming from Ruby I keep forgetting about it :)
<hightower2> wonderful, looks really clean
<hightower2> I need to check if array a includes all elements from array b. Any suggestions how to do it optimally?
<hightower2> (Int elements)
<Papierkorb> Are any of them sorted?
<FromGitter> <johnjansen> `a.all?(b)`
<oprypin> wait what
<FromGitter> <johnjansen> i think … its in enum
<oprypin> no
<oprypin> hightower2, by default it's an n squared complexity
<oprypin> make both of them into sets
rohitpaulk has quit [Ping timeout: 240 seconds]
<oprypin> or at least one of them
<oprypin> a.all? { |x| b_set.includes? x }
<FromGitter> <johnjansen> that was wrong, but the method is there … whats the magic incantation
<hightower2> Yes, they are sorted, I am comparing two Enumerable(Int)s while these originally come from Range(Int,Int) and from Range::StepIterator(Range(Int32, Int32), Int32, Int32)
<FromGitter> <johnjansen> haha, yeah … sorry about that
<Papierkorb> hightower2: So you want to know if range a includes range b?
<oprypin> Papierkorb, well it's stepiterator also which is annoying
<hightower2> Papierkorb, yes, but also Range::StepIterator, so I might have to compare 1..10 with 1,3,5,7,9
<oprypin> how i miss python's great abstractions sometimes
<Papierkorb> hightower2: Then both sets are sorted, you can do that in O(n) easily
<FromGitter> <johnjansen> you can do this ⏎ ⏎ ```other = [2,3] ⏎ all = (([1,2,3] & other).size == other.size)``` []
<oprypin> johnjanse, > it's an n squared complexity
<oprypin> stepiterator can have negative step
<oprypin> if you have two stepiterators with opposite steps it's impossible to compare them without saving at least one of them completely into memory
<Papierkorb> hightower2: #each over a, take an iterator over b. Then, check if the current element from a is the current element from b's iter. If yes, advance b's iter. Outside the #each, make sure b's iter is at its end.
<hightower2> that too, although it's still sorted, and in my case it doesn't matter if it's going 10..1 or 1..10. I can turn it around to avoid negatives.
rohitpaulk has joined #crystal-lang
<oprypin> basically stepiterator should not be an entity to deal with
<FromGitter> <johnjansen> how big are the arrays
<FromGitter> <bew> `puts [1, 3, 5].to_set.superset? [1, 5].to_set` ?
<hightower2> Small... couple elements usually, but max up to 1000 elements
<FromGitter> <johnjansen> and what types of elements
<hightower2> oprypin, yes, that's why I reduced the comparison to Enumerable(int) with Enumerable(Int), to avoid dealing with StepIterator and also because this same type matches both Ranges and StepIterator
<hightower2> johnjansen: all its
<hightower2> Ints32s
<FromGitter> <johnjansen> thanks
<Papierkorb> I already gave the algorithm for O(n).
<hightower2> Sure
<hightower2> Thanks!
<oprypin> Papierkorb, it is impossible to apply that algorithm
<Papierkorb> oprypin: Proof
<oprypin> i still recommend `a.all? { |x| b_set.includes? x }`
<oprypin> where b_set = b.to_set
<oprypin> Papierkorb, i dont have a proof, it's obvious > if you have two stepiterators with opposite steps it's impossible to compare them without saving at least one of them completely into memory
<hightower2> Papierkorb, if I have a = [ 1.. 10], and I have b which uses StepIterator, 2nd element in a will be 2, while 2nd in StepIterator will be 3
<hightower2> yes
<hightower2> 1..10 compared to (1..10).step(2)
<oprypin> if you can never have a negative step, then what Papierkorb is saying is good
<Papierkorb> oprypin: You have enumerables. I said that I assume them to be sorted in correct order. If both are true, my algorithm holds true.
<oprypin> hightower2, your example does not break Papierkorb's idea
<oprypin> >> 5.downto 1
<DeBot> oprypin: # => #<Int::DowntoIterator(Int32, Int32):0x2281fe0 @from=5, @to=1, @current=5> -
<hightower2> oh yes, I see
<oprypin> (10..1).step(-1)
<oprypin> >> (10..1).step(-1)
<DeBot> oprypin: # => #<Range::StepIterator(Range(Int32, Int32), Int32, Int32):0x1adafe0 @range=10..1, @step=-1, @current=10, @reached_end=false> -
<oprypin> hm weird stuff
<oprypin> >> (10..1).step(-1).to_a
<DeBot> oprypin: # => [] -
<oprypin> sorry for spam
<oprypin> so negative step is not a thing then. just need to exclude downtoiterator
<Yxhuvud> Why are you complicating so much? (x - y).empty? is what you want, where x is the elements that must be in y.
<oprypin> Yxhuvud, I don't think comparing 1..1000 and 2..1001 in a million operations is a good idea
<hightower2> haha
<hightower2> cool idea though, I didn't come to think of it :)
<Yxhuvud> oprypin: The question was about arrays, and the way I gave is not quadratic for that (unless the #- implementation has some really easy improvements that is possible). Ranges clearly have a better solution.
<hightower2> Ok, in the end I went with oprypin's suggestion of b.all?{ |i| a_set.includes? i}
<hightower2> thanks!
<oprypin> Yxhuvud, Array#- cant be better than quadratic
<Yxhuvud> huh?
<Yxhuvud> hint: check the implementation.
<oprypin> right, that...
<oprypin> then i guess Yxhuvud's way is the same thing but i guess with one more allocation
<FromGitter> <johnjansen> this might be a stupid question, but @hightower2 do you need to know if the items in b ARE in a, of that they MIGHT BE?
<FromGitter> <johnjansen> im assuming the answer is “ARE” ;-)
<FromGitter> <johnjansen> but just checking
<hightower2> johnjansen: ARE, I'm looking for behavior of (array a) includes? (array b)
<FromGitter> <johnjansen> nice, had to ask …
<FromGitter> <johnjansen> are you up for implementing a different data structure if necessary, or is that too bigger hammer?
<FromGitter> <johnjansen> i know you have a solution for now
DTZUZU has quit [Quit: WeeChat 1.5]
<hightower2> Sure, I'm up for ideas
Groogy has quit [Disconnected by services]
Groogy_ has joined #crystal-lang
greengriminal has joined #crystal-lang
<hightower2> Mm, pretty funny. I have a YAML converter, and when I call #to_yaml, the method does case( value) ... And I have "when Range(Int32, Int32)", but this case is not matched and instead the code goes to "else" in which I have "raise "Uknown type: #{value.class}"", and it reports value as being exactly Range(Int32,Int32).
<oprypin> hightower2, you lost me midway there
<oprypin> oh yeah i see
<oprypin> please just make a minimal reproducible example
<hightower2> Can't reproduce it. I did but that one works
<hightower2> I mean can't reproduce standalone. Still trying to figure it out.
rohitpaulk has quit [Ping timeout: 248 seconds]
<hightower2> I don't understand it, but at the top of the #to_yaml function (and most probably this isn't specific to #to_yaml), I have this:
<hightower2> puts "value.class=#{value.class}, value.inspect=#{value.inspect}, Range===value=#{Range===value}"
<hightower2> And when I run this, it says:
<hightower2> value.class=Range(Int32, Int32), value.inspect=4..6, Range===value=false
<hightower2> Which makes no sense. If in a standalone app I run "a=4..6; puts Range===a", it reports true of course.
<FromGitter> <bew> I don't see the issue (live:
Dreamer3 has joined #crystal-lang
<oprypin> hightower2, i remember someone tried to redefine ===
<hightower2> oprypin, hehe yes, I checked for that, I don't have any redefines of any operator on any class
<hightower2> (I had, but I removed all of them earlier today, triple-checked with grep etc.)
<FromGitter> <johnjansen> anyone got any suggestions about how to approach / isolate / avoid the following error, which occurs while trying to save a large msgpack string ⏎ ⏎ ```code paste, see link``` []
<oprypin> this error means "something somewhere went wrong"
<oprypin> so no, probably can't isolate it based on that
<FromGitter> <johnjansen> haha, yeah thats what i thought … would it make any sense to try this with crystal 0.22.0 ?
<FromGitter> <johnjansen> it 0.23 now
<oprypin> i dont know
<FromGitter> <johnjansen> ok … makes 2 of us ;-)
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
Dreamer3 has quit [Remote host closed the connection]
Dreamer3 has joined #crystal-lang
bjz has joined #crystal-lang
<RX14> @johnjansen your best bet is commenting out [this]( line, rebuilding, and then using gdb
<RX14> we really should have a flag to disable the sigfault handler
<FromGitter> <johnjansen> @RX14 just the person i need ;-)
<FromGitter> <johnjansen> im trying to serialize the NET tst to msgpack (serialize branch of TST) … this is happening at the 32+M mark … and its not related to write, i cant even pack.size without the problem … trying to isolate now (running tst.words to see if its our side)
<FromGitter> <johnjansen> at least as a starting point
<RX14> shouldn't be anything unsafe now
<RX14> did you compile without --release?
<FromGitter> <johnjansen> i did not
<FromGitter> <johnjansen> i will try that
<RX14> it'd get you a much better stacktrace
<RX14> well
<RX14> maybe
<FromGitter> <johnjansen> its not 0.23.0 either as i tried with 22
<FromGitter> <johnjansen> rescue wont trap it either … just bails out
<FromGitter> <johnjansen> actually it *might* be to_msgpack ...
<RX14> yeah lol a rescue won't rescue a sigfault
<RX14> there's really no recoverable action
<FromGitter> <johnjansen> haha, i expect more ;-)
<FromGitter> <johnjansen> its `to_msgpack` so yeah …
<RX14> yeah maybe msgpack is playing with pointers
<RX14> it shouldn't do
<RX14> well i havent looked at the code
<RX14> maybe there is valid reason
<RX14> but whatever it is it went wrong here
<FromGitter> <johnjansen> yep same old same old, just calling `tst.to_msgpack` results in ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <johnjansen> ok divide and conquer and try to find which entry is causing this
<oprypin> johnjansen, how about trying an older version of msgpack
<oprypin> oh but that will probably also need older crystal
<FromGitter> <johnjansen> it seems to be a combination of data and msgpack … im trying to narrow it down, its somewhere within about 2M records
<oprypin> good job
<FromGitter> <johnjansen> 1M
<FromGitter> <johnjansen> i’d do this programmatically, but the error cant be trapped
<oprypin> write a bash script lol
<FromGitter> <johnjansen> yeah, trying to keep the scope small ;-)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<oprypin> i dont see any negligence of unsafe constructs in a quick scan of msgpack source code
<FromGitter> <johnjansen> yeah i dont know if thats it … im sure it will turn out to be obvious but for now, its now
<FromGitter> <johnjansen> ```code paste, see link``` []
bjz has joined #crystal-lang
<RX14> looks like i'm wrong
<FromGitter> <johnjansen> never
<RX14> you can use gdb without disabling the sigfault handler
<RX14> and it works
<FromGitter> <johnjansen> @RX14 i narrowed it to between 35_900_000 and 36_250_000, however, narrow that range at EITHER end and the issue goes away
<FromGitter> <johnjansen> 5K increments at this stage
<FromGitter> <johnjansen> something damn strange is happening … and im not convinced its msgpack either
<oprypin> too bad i won't be around for the thrilling conclusion
<FromGitter> <johnjansen> lol
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hightower2> Something funky on my side too. I run the class/value test as shown here:
<hightower2> And in the example of course the result of those tests us true, as it should be
greengriminal has quit [Quit: This computer has gone to sleep]
<hightower2> But in my case here, I get false to all of the tests, including === and is_a?
<hightower2> And I for sure didn't override any of these methods.
<oprypin> hightower2, you gotta isolate it though. if you cant any further, at least put it in 1 file and show it
<hightower2> Yeah I'll try that, will try putting in one file and trimming down the code until it either becomes isolated or I identify which block of code made a difference
<hightower2> Got it reproduced in single-file approach, now to trim
<FromGitter> <johnjansen> if i gsub out downcase.gsub(/[^a-z0-9\-\.]+/, “") it works
<oprypin> gsub out gsub?
<oprypin> that must be your code
<FromGitter> <johnjansen> damn … just moved the problem
Dreamer3 has quit [Remote host closed the connection]
Dreamer3 has joined #crystal-lang
Dreamer3 has quit [Ping timeout: 268 seconds]
<hightower2> Mm, oprypin , I got somewhere. I have my type defined as: alias Virtual = Nil | Int32 | Bool | Range(Int32, Int32) | Enumerable(Int32) | Proc(Int32, Bool). And even though my object is Range(Int32,Int32), the existence of Enumerable in this list made that be preferrable over the explicit Range(Int32,Int32) type. My mistake was that I didn't check typeof(). When Enumerable is not in the list, typeof() reports (Bool | Int32 | P
<hightower2> roc(Int32, Bool) | Range(Int32, Int32)). When it is in the list, typeof() reports (Bool | Enumerable(Int32) | Int32 | Proc(Int32, Bool))
<hightower2> Not sure if this is some kind of a bug/problem, or just an unintuitive, but correct/expected behavior.
<FromGitter> <johnjansen> @hightower2 code?
<hightower2> There we go:
<hightower2> ( johnjansen, oprypin )
bjz has joined #crystal-lang
greengriminal has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: Leaving]
<oprypin> good job
<oprypin> now all that's left is to report a bug, no happy end
Ven has joined #crystal-lang
Ven is now known as Guest56511
<hightower2> oprypin, oh you confirm it's a bug?
<hightower2> (I don't understand the type system enough to know if it is or not)
bjz has joined #crystal-lang
<hightower2> To me it seems it is (at least) not respecting the order in which types are specified
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hightower2 has quit [Read error: Connection reset by peer]
<FromGitter> <johnjansen> looks like a bug @hightower2 @oprypin
hightower2 has joined #crystal-lang
Philpax has joined #crystal-lang
<hightower2> Here is minimal example:
<FromGitter> <johnjansen> is it only the range type which mis-identifies
hightower2 has quit [Ping timeout: 258 seconds]
<FromGitter> <bew> Wow that's weird
tzekid has quit [Remote host closed the connection]