Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 17 20:20
    Blacksmoke16 synchronize #12044
  • May 17 18:19
    straight-shoota edited #11947
  • May 17 18:19
    straight-shoota milestoned #11947
  • May 17 18:18
    straight-shoota closed #11971
  • May 17 18:18
    straight-shoota closed #11970
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil opened #12063
  • May 17 16:29
    HertzDevil labeled #12062
  • May 17 13:50
    hugopl opened #12062
  • May 17 13:50
    hugopl labeled #12062
  • May 16 19:05
    lbguilherme synchronize #11947
  • May 16 17:29
    straight-shoota milestoned #11971
  • May 16 17:15
    straight-shoota closed #12038
  • May 16 17:15
    straight-shoota closed #12036
  • May 16 17:14
    straight-shoota edited #12038
  • May 16 13:47
    straight-shoota closed #12051
  • May 16 13:47
    straight-shoota closed #12050
  • May 16 12:17
    beta-ziliani edited #7318
nanobowers
@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
George Dietrich
@Blacksmoke16
crystal doesn't have global vars
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
nanobowers
@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()
Thanks for all of the help/advice
YusufCakan
@YusufCakan
how to people normally debug the crystal compiler. Are there any instructions on how to do this.
Jonathan Silverman
@mixflame
confirmed amber redis websocket adapter patch is stable and works with multiple amber processes :D
+tests added+
From IRC (bridge bot)
@FromIRC
<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?
Quinton Miller
@HertzDevil
you cannot traverse backwards with an Enumerable, but there's rindex for Indexable
From IRC (bridge bot)
@FromIRC
<jhass[m]> has some yet unhandled edge cases around the only match being the first one or no match of course
Quinton Miller
@HertzDevil
From IRC (bridge bot)
@FromIRC
<jhass[m]> Indexable#rfind could use reverse_each and break I guess
From IRC (bridge bot)
@FromIRC
<postmodern> how do i specify a literal ASCII string? "\xff\xfe" is being interpreted as a unicode string with one character instead of two
Ali Naqvi
@naqvis
"\u{ff}\u{fe}" if two separate chars
From IRC (bridge bot)
@FromIRC
<postmodern> ah, weird syntax but that seems to work
<postmodern> ah but that defines a unicode string of four bytes. i need a two-byte string of 0xff and 0xfe
Ali Naqvi
@naqvis
"\xff\xfe" is actually two byte String
pp "\xff\xfe".to_slice # => Bytes[255, 254]
can you please describe, what are you getting? and what's your expected output?
From IRC (bridge bot)
@FromIRC
<postmodern> i think the problem is because my code is using String#chars which returns unicode characters
Ali Naqvi
@naqvis
but FF FE is a UTF16-LE BOM
From IRC (bridge bot)
@FromIRC
<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
Ali Naqvi
@naqvis

pp "\u{ff}\u{fe}".chars # => ['ÿ', 'þ']

this is correct representation

From IRC (bridge bot)
@FromIRC
<postmodern> bytes shows extra unicode stuff in there [195, 191, 195, 190]
George Dietrich
@Blacksmoke16
are they multibyte chars?
From IRC (bridge bot)
@FromIRC
<postmodern> they shouldn't be, but i guess they are being interpreted as such
Ali Naqvi
@naqvis
since String is UTF-8 but you are dealing with UTF-16
so you should be invoking "\u{ff}\u{fe}".to_utf16 to get the correct byte representation
From IRC (bridge bot)
@FromIRC
<postmodern> crystal's utf8-by-default Strings are making it hard for me to define a String of garbage ASCII data
Ali Naqvi
@naqvis
for encoding other than UTF-8 you should be using stream instead of String
From IRC (bridge bot)
@FromIRC
<postmodern> ah ha, thanks
From IRC (bridge bot)
@FromIRC
<postmodern> curious why String.new(Bytes[0xff, 0xfe]).chars.map(&.ord) returns [65533, 65533]
<postmodern> ah ha, i probably want to check String#valid_encoding? and check String#chars otherwise check String#bytes.
Ali Naqvi
@naqvis
its because that's not valid UTF-8
String.from_utf16("\u{ff}\u{fe}".to_utf16).chars.map(&.ord) # => [255, 254]
From IRC (bridge bot)
@FromIRC
<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
From IRC (bridge bot)
@FromIRC
<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
From IRC (bridge bot)
@FromIRC
<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.
didactic-drunk
@didactic-drunk
How do you get a String Class::Name.method_name from a macro for the current method?
George Dietrich
@Blacksmoke16
{{"#{@type.name.id}.#{@def.name.id}".id}} would prob do it
didactic-drunk
@didactic-drunk
@what for the caller?
George Dietrich
@Blacksmoke16
is Class::Name the same as the class the method is in?