<FromGitter>
<mixflame> hopefully someone merges my stuff soon, it works to give scalability in websocket apps on amber
jrayhawk_ is now known as jrayhawk
SeedyROM has quit [Quit: Leaving]
delucks has joined #crystal-lang
<delucks>
hey folks! I'm trying to compile a Crystal "hello world" on a SPARCv9 machine running OpenBSD6.8 using LLVM 10. I've built a ll file of the code on a x86 machine running the latest release of the compiler, but when building it on the target machine using llc, I get a segfault running DAG Pattern Instruction Selection. LLVM claims to support this target triplet :) Has anyone successfully compiled Crystal
<FromGitter>
<Blacksmoke16> i dont see it on there so would prob need a PR to support it
SeedyROM has joined #crystal-lang
ur5us_ has quit [Ping timeout: 246 seconds]
<delucks>
thanks Blacksmoke16. Do you have any suggestions for how to debug this llvm compilation failure and get more info about where in the crystal codebase needs to be modified?
<delucks>
thanks, super helpful. is there a process for accepting new architectures like this, or would that be a discussion for a future PR?
<FromGitter>
<Blacksmoke16> afaik the last one just made a PR
<FromGitter>
<Blacksmoke16> that would probably suffice
<FromGitter>
<Blacksmoke16> could prob reference the rust implementation of the abi as it also uses llvm
ur5us_ has joined #crystal-lang
deavmi_ has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
mike_onlooker has joined #crystal-lang
<FromGitter>
<nanobowers> Hello all, new to crystal and trying to migrate some ruby code to crystal in an attempt to learn it. I'm trying to port something that uses rspec yield matchers: https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/yield-matchers ⏎ and cannot seem to find a feature in Crystal's `Spec` that has equivalent functionality. Did I miss something, or is there a shard that does this?
<FromGitter>
<Blacksmoke16> whats the thing you're wanting to test?
<FromGitter>
<Blacksmoke16> id just test that versus worrying about how many times something yields or something
<FromGitter>
<nanobowers> Also, if anyone knows of a cheat-sheet (mapping) of ruby stdlib to crystal stdlib, that would be helpful. There are a lot of similarities, but also plenty of differences and a lot of hunting to find the *nearly* equivalent thing
<FromGitter>
<mixflame> whew ok ⏎ Amber patch is perfect, 2 tests, working, and confirmed you don't have to use the hack anymore.
<FromGitter>
<nanobowers> @Blacksmoke16 For this particular thing i could creat an array and successively yield to construct it, but for some streaming cases maybe that wont work... In this particular case, i picked up a utility written in ruby with rspec tests that i didnt write and have little familiarity with - I was hoping to spend more time in the code and just migrate the tests as closely as possible, but now i'll have a
<FromGitter>
... chance to explore both in more detail.
<FromGitter>
<Blacksmoke16> can you share the code?
<FromGitter>
<Blacksmoke16> or something along those lines?
<FromGitter>
<Blacksmoke16> wayy more readable imo
<FromGitter>
<Blacksmoke16> `Layout.new`*
<FromGitter>
<Blacksmoke16> or whatever the type is
<FromGitter>
<nanobowers> Yeah, probably so... I've used rspec for some time and never seen even half of the stuff i've seen used in this code.
<FromGitter>
<Blacksmoke16> Spec module is deff a lot more simplistic than rspec, IMO for the better most of the time
<FromGitter>
<nanobowers> Are 'named' globals available? Saw very little discussion in the documentation and the compiler complains when the long-name versions of builtin globals are used e.g. $0 vs $PROGRAM_NAME and $? vs $CHILD_STATUS
<FromGitter>
<Blacksmoke16> crystal doesn't have global vars
<FromGitter>
<Blacksmoke16> at least that the user can define on their own. The only real global vars are defined via the compiler, which are like `$~` and `$1`, `$n` representing regex matches
<FromGitter>
<nanobowers> Makes sense, will need to add that to my list of things to find the Ruby equivalent for - I think i've figured out $? equiv vias Process.run()
<FromGitter>
<nanobowers> Thanks for all of the help/advice
aquijoule_ has joined #crystal-lang
richbridger has quit [Ping timeout: 246 seconds]
SeedyROM has quit [Quit: Leaving]
ur5us_ has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 252 seconds]
lucf117 has quit [Quit: Leaving]
mike_onlooker has quit [Ping timeout: 246 seconds]
<FromGitter>
<YusufCakan> how to people normally debug the crystal compiler. Are there any instructions on how to do this.
<FromGitter>
<mixflame> confirmed amber redis websocket adapter patch is stable and works with multiple amber processes :D
<FromGitter>
<mixflame> +tests added+
ur5us has joined #crystal-lang
<postmodern>
is there an Enumerable method that finds the last occurance based on a block?
<jhass[m]>
mmh, I don't think so but could maybe concort something with with_index and max?
<FromGitter>
<HertzDevil> you cannot traverse backwards with an `Enumerable`, but there's `rindex` for `Indexable`
<FromGitter>
<naqvis> can you please describe, what are you getting? and what's your expected output?
<postmodern>
i think the problem is because my code is using String#chars which returns unicode characters
<FromGitter>
<naqvis> but `FF FE` is a UTF16-LE BOM
<postmodern>
yeah, kind of wish Crystal had a way to forcibly defining an ASCII string, so you can contain non-UTF binary strings of random data that could be misinterpreted as UTF codepoints
<FromGitter>
<naqvis> `pp "\u{ff}\u{fe}".chars # => ['ÿ', 'þ']` ⏎ ⏎ this is correct representation
<postmodern>
bytes shows extra unicode stuff in there [195, 191, 195, 190]
<FromGitter>
<Blacksmoke16> are they multibyte chars?
<postmodern>
they shouldn't be, but i guess they are being interpreted as such
<FromGitter>
<naqvis> since `String` is UTF-8 but you are dealing with UTF-16
<FromGitter>
<naqvis> so you should be invoking `"\u{ff}\u{fe}".to_utf16` to get the correct byte representation
<postmodern>
crystal's utf8-by-default Strings are making it hard for me to define a String of garbage ASCII data
<postmodern>
well got specs passing. good enough for now.
<jhass[m]>
I still wish we kept String at enforced valid UTF-8 only and instead developed better tooling around Bytes
<jhass[m]>
the dual use of String as character and byte array is a C ism that has no real place in a high level language IMO. It's probably my biggest gripe with Ruby
<postmodern>
as long as you don't end up going the route of python3's byte arrays vs utf8 strings. that seems to be creating a lot of friction.
<postmodern>
i'd be happy if String#valid_encoding? # => false, then the String would fallback to raw ASCII where #chars would be the ASCII bytes converted to ASCII 8bit chars.
<postmodern>
seems a bit magic with how String tries its best to convert non-UTF byte sequences to UTF chars. idk, i need to sleep.
postmodern has quit [Quit: Leaving]
notzmv has joined #crystal-lang
notzmv has quit [Ping timeout: 246 seconds]
notzmv has joined #crystal-lang
notzmv has quit [Ping timeout: 246 seconds]
notzmv has joined #crystal-lang
Flipez has quit [Changing host]
Flipez has joined #crystal-lang
notzmv has quit [Ping timeout: 240 seconds]
<FromGitter>
<didactic-drunk> How do you get a `String` `Class::Name.method_name` from a macro?
<FromGitter>
<Blacksmoke16> `{{"#{@type}.#{@def.name.id}".id}}` would prob do it
<FromGitter>
<didactic-drunk> `@what` for the caller?
<FromGitter>
<Blacksmoke16> is `Class::Name` the same as the class the method is in?
<FromGitter>
<Blacksmoke16> what would `to_i32!` to diff than `.to_i`?
<FromGitter>
<Blacksmoke16> do diff*
<FromGitter>
<vgramkris> if you see above, in line 2, assignment to be works fine
<FromGitter>
<vgramkris> but line 4 is an issue
<FromGitter>
<Blacksmoke16> right, can't you just call `c.to_i32`?
<FromGitter>
<vgramkris> so if the String cannot be typecasted to i32 then i expect nil instead of a exception
<FromGitter>
<Blacksmoke16> it'll raise on over/under flow iirc
<FromGitter>
<vgramkris> thats right, that is what i am trying to overcome with the '!'
<FromGitter>
<Blacksmoke16> you're getting a compile time error not an over/underflow exception
<FromGitter>
<Blacksmoke16> if you want it to wrap, try `.to_i32?`
<FromGitter>
<vgramkris> yep thats right
<FromGitter>
<Blacksmoke16> so im not sure i see the problem?
<FromGitter>
<Blacksmoke16> going from a number to number has diff semantics than a string to a number, which is probably why they have slightly diff conversion methods
<FromGitter>
<vgramkris> yeah exactly, so num to num with ! we can do both checking & assignment in same line
<FromGitter>
<vgramkris> but from string to num i need to check with .to_i32? and then assign
<FromGitter>
<vgramkris> that is what i was trying to understand if there is any reason why for string they did not have .to_i32! while they do have .to_i32 for string
<FromGitter>
<Blacksmoke16> still not sure i follow, you deff can do like `d : Int32 | Nil = c.to_i32?`
<FromGitter>
<Blacksmoke16> because `to_i32!` represents a wrapping operation on the value if it over/underflows. In the case of a string its `to_i32?` because you cant wrap a string, and needs to handle the case of the string not being a number. So it'll return `nil` if either of those happens
<FromGitter>
<vgramkris> okay this makes sense.. thanks!
<FromGitter>
<Blacksmoke16> there is a block version of `to_i32` that you can use. Which will use the blocks value in case of under/overflow or its not a valid number