ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | 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
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <Blacksmoke16> is there a good way to support a method like `def foo(value, flag = false)` that delegates to `def foo(*values, flag = false)` without causing infinite recursion?
<FromGitter> <Blacksmoke16> like use the first if only 1 input, use the other for more than 1?
<FromGitter> <elementio:salt-rock-lamp.ems.host> What about `foo(val1, val2, *vals)`, if you want to use multiple dispatch like that
<FromGitter> <elementio:salt-rock-lamp.ems.host> In other languages I'd have 2 separate functions, or rely on higher order functions to "pack" or "unpack" the positional parameters as needed
<FromGitter> <Blacksmoke16> ended up with just making it 1 function with splat, and just require you used a named arg for the flag value
<FromGitter> <Blacksmoke16> lol this is a first `Error: do you maybe have a typo in this 'intiailize' method?`
<FromGitter> <Blacksmoke16> but it was correct :P
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
andremedeiros has quit [Client Quit]
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Ping timeout: 260 seconds]
<FromGitter> <rishavs> Is there a way to limit the max request size in an http server? I was wondering if this can be a possible DOS vector.
hendursaga has joined #crystal-lang
hendursa1 has quit [Ping timeout: 240 seconds]
_ht has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> @rishavs: put it behind nginx anyway
<FromGitter> <rishavs> πŸ‘
<FromGitter> <rishavs> Is something broken with json mapping in 1.0? ⏎ I just tried an example from the api documentation https://crystal-lang.org/api/0.23.1/JSON.html#mapping%28properties%2Cstrict%3Dfalse%29-macro ⏎ and it is throwing the error `Error: undefined method 'mapping' for JSON:Module` ⏎ The code is at ⏎ https://play.crystal-lang.org/#/r/az12 [https://gitter.im/crystal-lang/crystal?at=6083f26bd795391861798b8a]
<FromGitter> <naqvis> `JSON.mapping` is no longer part of stdlib. That has long been moved out to separate shard
<FromGitter> <naqvis> so if you still prefer to use `JSON.mapping`, you will have to use that shard
<FromGitter> <rishavs> Thanks for the heads up! looks like the api docs are not fully updated
<FromGitter> <naqvis> you are looking into old docs
<FromGitter> <rishavs> you are right sir. I am being an idiot today. lol. I guess I need more coffee....
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
Nekka has quit [Client Quit]
Nekka has joined #crystal-lang
Nekka has quit [Ping timeout: 252 seconds]
Nekka has joined #crystal-lang
mipmip has joined #crystal-lang
DTZUZU has joined #crystal-lang
DTZUZU_ has quit [Ping timeout: 246 seconds]
postmodern has joined #crystal-lang
mipmip has quit [Ping timeout: 245 seconds]
mipmip has joined #crystal-lang
<FromGitter> <Sija> Hi all, I have a Crystal-oriented post to review for anyone interested - https://sija.pl/en/notes/crystal-docset-for-dash-app πŸ™ Any criticism or comments are more than welcome, thanks! :)
<FromGitter> <tenebrousedge> @Sija looks good to me πŸ‘
<FromGitter> <Sija> @tenebrousedge thanks for the feedback πŸ™‡β€β™‚οΈ
mipmip has quit [Ping timeout: 252 seconds]
<straight-shoota> @Sija Do you realize the API docs are available as a targz for every release? There's really no need to crawl the website for that
<FromGitter> <tenebrousedge> huh, I didn't take a look at the scripts
<FromGitter> <Sija> @straight-shoota I do, but that was easier :P
<straight-shoota> How so?
<FromGitter> <Sija> And `/reference/` still needs to be dl-ed
<FromGitter> <Blacksmoke16> is there anything in the stdlib like https://www.php.net/manual/en/function.mb-strwidth.php#refsect1-function.mb-strwidth-examples at the moment?
<FromGitter> <oprypin:matrix.org> @Blacksmoke16: what *is* this, though?
<FromGitter> <Sija> Well, I concluded that finding the proper url of the release docs would be moar time consuming ;)
<FromGitter> <Blacksmoke16> my understanding is that it returns the number of character "slots" a specific character takes up
<FromGitter> <Blacksmoke16> like how many characters wide it is when rendered on like a console or something
<FromGitter> <Sija> https://github.com/crystal-lang/crystal/releases/download/1.0.0/crystal-1.0.0-docs.tar.gz is easy but if there’s another revision, like `1.0.0-1` the docs url won’t be symmetrical
mipmip has joined #crystal-lang
<straight-shoota> There are no release revisions. And if there were, they would be reflected in https://crystal-lang.org/api/ paths.
<FromGitter> <Sija> @Blacksmoke16 u mean `String#bytesize`?
<FromGitter> <oprypin:matrix.org> @Blacksmoke16: the existence of this function really surprises me
<FromGitter> <tenebrousedge> bytesize is not correct for that purpose @Sija
<FromGitter> <oprypin:matrix.org> well on my terminal that character -a- just messes up spacings, the terminal gives up on being monospace :D
<FromGitter> <Sija> @straight-shoota as far as I can see `1.0.0` is a `1.0.0-1` release
<FromGitter> <oprypin:matrix.org> @Sija: it's just the debian package
<straight-shoota> the distribution packages have -1 revision, yes
<straight-shoota> but the targz with the docs does not have revisions
<straight-shoota> It's just 1:1 the same as on the crystal-lang.org/api
<FromGitter> <Blacksmoke16> @Sija that seems different, returns `3` in the example
<FromGitter> <Blacksmoke16> @oprypin:matrix.org yea i never really thought about this, prob will just use `size` and not worry about it...
<straight-shoota> that width thing seems to be relevant for east asian character sets
<FromGitter> <oprypin:matrix.org> @Blacksmoke16: i'm really curious, what width does it say for ZERO-WIDTH JOINER
<FromGitter> <tenebrousedge> for an equivalent method I think you would have to use `codepoints` and the list of fullwidth characters
<FromGitter> <Blacksmoke16> looks to be `6`
<FromGitter> <Blacksmoke16> `var_dump(mb_strwidth("\u200D")); # => int(6)`
<FromGitter> <tenebrousedge> remind me never to care about this problem 😬
<FromGitter> <oprypin:matrix.org> O_O
<FromGitter> <Blacksmoke16> fwiw the PHP method im looking at only uses this for non UTF-8 chars, otherwise falls back on https://www.php.net/manual/en/function.strlen.php
<FromGitter> <oprypin:matrix.org> the actual width is 0 but it says 6 -- what ? like how?
<FromGitter> <Blacksmoke16> `var_dump(strlen("\u200D")); # => int(6)`
<FromGitter> <Blacksmoke16> wait
<FromGitter> <Blacksmoke16> sorry i messed that up, was using crystal syntax
<FromGitter> <Blacksmoke16> ```var_dump(mb_strwidth("\u{200D}")); # => int(1) ⏎ var_dump(strlen("\u{200D}")); # => int(3)``` [https://gitter.im/crystal-lang/crystal?at=608467c3d7953918617a8fba]
<FromGitter> <oprypin:matrix.org> well see, it's wrong in that case at least
<FromGitter> <Blacksmoke16> ```"\u200D".bytesize # => 3 ⏎ "\u200D".size # => 1``` [https://gitter.im/crystal-lang/crystal?at=608467f8dc24646812dfd2a7]
<FromGitter> <Blacksmoke16> in crystal land
<FromGitter> <oprypin:matrix.org> so i'd say that this exact function is not usable as a good approximation of text width
<straight-shoota> width has _nothing_ to do with encoding properties (byte size), it's a purly visual property
<FromGitter> <Blacksmoke16> the docs do say halfwidth chars are considered 1, which might be the case here?
<straight-shoota> I'd assume every latin character is halfwidth, because it surely isn't full width
<straight-shoota> that should be true for any character that is not from an east-asian character set
<FromGitter> <Blacksmoke16> > The fullwidth characters are: U+1100-U+115F, U+11A3-U+11A7, U+11FA-U+11FF, U+2329-U+232A, U+2E80-U+2E99, U+2E9B-U+2EF3, U+2F00-U+2FD5, U+2FF0-U+2FFB, U+3000-U+303E, U+3041-U+3096, U+3099-U+30FF, U+3105-U+312D, U+3131-U+318E, U+3190-U+31BA, U+31C0-U+31E3, U+31F0-U+321E, U+3220-U+3247, U+3250-U+32FE, U+3300-U+4DBF, U+4E00-U+A48C, U+A490-U+A4C6, U+A960-U+A97C, U+AC00-U+D7A3, U+D7B0-U+D7C6, U+D7CB-U+D7FB,
<FromGitter> ... U+F900-U+FAFF, U+FE10-U+FE19, U+FE30-U+FE52, U+FE54-U+FE66, U+FE68-U+FE6B, U+FF01-U+FF60, U+FFE0-U+FFE6, U+1B000-U+1B001, U+1F200-U+1F202, U+1F210-U+1F23A, U+1F240-U+1F248, U+1F250-U+1F251, U+20000-U+2FFFD, U+30000-U+3FFFD. All other characters are halfwidth characters.
mipmip has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> yup, sounds right ^
<FromGitter> <Blacksmoke16> so this is prob something like `for each char in a string reduce the size, adding 1 for halfwidth and 2 if the char is in this list of fullwidth`
<straight-shoota> yeah
<FromGitter> <tenebrousedge> yes, but visual width is probably a different property
<FromGitter> <oprypin:matrix.org> @Blacksmoke16: so we have figured out what that php function does. but what functionality are you actually looking for?
<FromGitter> <Blacksmoke16> porting some PHP code and it was using that
<straight-shoota> The only use case I can think of is when you want to calculate the width of a string in a monospaced font. Usually that's just the number of characters. But full-width chracters are are two characters wide.
<straight-shoota> Then there's still zero-width charachters, though
<straight-shoota> What purpose does it have in the PHP code you're porting?
<FromGitter> <tenebrousedge> it's probably incorrect in that code
<straight-shoota> I'd bet on that, too ^^
<FromGitter> <oprypin:matrix.org> same
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ is for some CLI stuff so i assume they're using it to know how to build the CLI elements so everything is even no matter the chars used [https://gitter.im/crystal-lang/crystal?at=60846a16ae90f368409f883b]
<FromGitter> <tenebrousedge> unless a character is zero width or an em dash or...
<straight-shoota> okay, that sounds a lot like the use case I came up with
<FromGitter> <Blacksmoke16> yea, for reference: https://github.com/symfony/symfony/issues/40634
<FromGitter> <oprypin:matrix.org> i think that it misses more cases than it satisfies. so just don't bother and use .size
<postmodern> if you want to define an interface that accepts any object which defines a certain method (ex: each_byte(&)), is that possible or do you leave the type definition blank and let the compiler handle things?
<straight-shoota> let the compiler handle things
<FromGitter> <oprypin:matrix.org> postmodern, yea just leave it blank
<FromGitter> <oprypin:matrix.org> wait.. not sure we both meant it the same way
<FromGitter> <oprypin:matrix.org> leave the type restriction black
<FromGitter> <oprypin:matrix.org> blank*
<FromGitter> <oprypin:matrix.org> no interface
<FromGitter> <Blacksmoke16> on a related note, i need to fix my fonts all i see are boxes :S
<oprypin> Blacksmoke16, install noto-fonts
<FromGitter> <Blacksmoke16> i imagine its just not that simple, didnt seem to help?
<FromGitter> <oprypin:matrix.org> maybe not enough things were restarted and/or caches flushed
<FromGitter> <Blacksmoke16> think i need to add them to X11 or something sec
<FromGitter> <oprypin:matrix.org> uh i think X11 does not participate in font rendering
<FromGitter> <tenebrousedge> fontconfig is probably a thing
<FromGitter> <Blacksmoke16> :shrug: wiki said you need to added via a `FontPath` entry in xorg.conf
<FromGitter> <Blacksmoke16> it needed to be*
<FromGitter> <tenebrousedge> anything mentioning `xorg.conf` is likely outdated
<FromGitter> <oprypin:matrix.org> @Blacksmoke16: that is wrong or is done for some other purpose
<FromGitter> <Blacksmoke16> ah it was under the "manual install" instructions
<FromGitter> <Blacksmoke16> anyway i rebooted as well, will see if i still notice them
<FromGitter> <Blacksmoke16> and yea prob just going to use `.size` and worry about it if/when it becomes an issue
<FromGitter> <Sija> @straight-shoota It finally clicked why did I before ignore the docs tar file - it complicates the flow for the `master` docs
<FromGitter> <oprypin:matrix.org> @Sija: i wouldn't choose to even download the docs like that, would rather build them
<FromGitter> <Sija> yeah, I thought of that but seemed like an overkill
<FromGitter> <BracketMaster> currently checking out crystal - does superator work in crystal?
<FromGitter> <BracketMaster> or really - any way to do custom operators?
<FromGitter> <Blacksmoke16> idk what that is so im going to go with no
<FromGitter> <BracketMaster> https://github.com/jicksta/superators
<FromGitter> <BracketMaster> superator is from ruby
<FromGitter> <tenebrousedge> probably you could write that
<FromGitter> <BracketMaster> So I'm trying to implement a hardware description language in Crystal - and want the `:=` operator
<FromGitter> <Blacksmoke16> gl
<FromGitter> <BracketMaster> for hardware assignments
<FromGitter> <Blacksmoke16> idt that's valid syntax on the syntax level so would need compiler support
<FromGitter> <BracketMaster> alright - I suspected as much
<FromGitter> <tenebrousedge> yeah `:=` would not be valid
<FromGitter> <BracketMaster> superator uses macros in ruby
<FromGitter> <BracketMaster> not sure about Crystal's macro situation
<FromGitter> <tenebrousedge> you can write Crystal macros
<FromGitter> <tenebrousedge> but I don't think you can do `:=` even with macros
<FromGitter> <tenebrousedge> Crystal has macros, Ruby has metaprogramming
<FromGitter> <Blacksmoke16> tl;dr operators in crystal need to be valid method names (for the most part)
<FromGitter> <tenebrousedge> does superator allow `:=` ? I don't see `:` in the regex there
<jhass> last commit 2008, I think I'd look strangely at you for using this in ruby too :D
<jhass> yeah it too exploits only valid syntax
<jhass> no := for sure
<jhass> and who knows if this even still works on 1.9+ given it's 13 years old
<FromGitter> <tenebrousedge> what is the use case for `:=`?
_ht has quit [Remote host closed the connection]
<FromGitter> <BracketMaster> using `:=` for hardware assignements
<FromGitter> <Blacksmoke16> got an example?
<FromGitter> <BracketMaster> yes
<FromGitter> <BracketMaster> not in Crystal
<FromGitter> <BracketMaster> but in scala
<FromGitter> <BracketMaster> Chisel is a scala DSL used by silicon companies such as SiFive
<FromGitter> <BracketMaster> SiFive makes RISC-V processors
<FromGitter> <Blacksmoke16> i mean how is it different than `a = 1`?
<FromGitter> <BracketMaster> `io.out := count`
<FromGitter> <BracketMaster> ah
<FromGitter> <Blacksmoke16> `io.out = count`?
<FromGitter> <BracketMaster> its not an assignment
<FromGitter> <BracketMaster> in chisel - it tells the hardware collector pass to mark that and add it as a node to the hardware AST representation
<FromGitter> <Blacksmoke16> oh so its just like a custom overload of the method called `:=`
<FromGitter> <BracketMaster> yup
<FromGitter> <Blacksmoke16> yea youd have to use another method
<FromGitter> <BracketMaster> no worries
<FromGitter> <BracketMaster> also - there isn't really a straightforward path to run crystal on Apple Silicon it seems
<straight-shoota> Not yet. Arch support was only added in LLVM 11
<jhass> installing and running from an x86 homebrew installation seems fine at first glance
<jhass> arch -x86_64 <homebrew install command>; arch -x86_64 /usr/local/bin/brew install crystal
<straight-shoota> but that only runs via rosetta, not on the M1, right? You still need to cross-compile for that.
<straight-shoota> *natively on the M1
<jhass> yeah, it runs everything through rosetta
<jhass> but one barely notices
DTZUZU has quit [*.net *.split]
xybre has quit [*.net *.split]
straight-shoota has quit [*.net *.split]
markmarkmark has quit [*.net *.split]
Nekka has quit [*.net *.split]
bougyman has quit [*.net *.split]
repo has quit [*.net *.split]
hendursaga has quit [*.net *.split]
deavmi has quit [*.net *.split]
chachasmooth has quit [*.net *.split]
Vexatos has quit [*.net *.split]
avane has quit [*.net *.split]
richbridger has quit [*.net *.split]
dostoyevsky has quit [*.net *.split]
r0bby has quit [*.net *.split]
duane has quit [*.net *.split]
Stephanie has quit [*.net *.split]
maxpowa has quit [*.net *.split]
Seich has quit [*.net *.split]
Xeago has quit [*.net *.split]
fifr` has quit [*.net *.split]
sorcus has quit [*.net *.split]
Flipez has quit [*.net *.split]
astronavt has quit [*.net *.split]
oz has quit [*.net *.split]
early has quit [*.net *.split]
badeball has quit [*.net *.split]
johnny101 has quit [*.net *.split]
DTZUZU has joined #crystal-lang
xybre has joined #crystal-lang
bougyman has joined #crystal-lang
straight-shoota has joined #crystal-lang
markmarkmark has joined #crystal-lang
repo has joined #crystal-lang
Nekka has joined #crystal-lang
hendursaga has joined #crystal-lang
early has joined #crystal-lang
johnny101 has joined #crystal-lang
badeball has joined #crystal-lang
entel has quit [Ping timeout: 261 seconds]
Flipez has joined #crystal-lang
oz has joined #crystal-lang
astronavt has joined #crystal-lang
sorcus has joined #crystal-lang
Stephanie has joined #crystal-lang
duane has joined #crystal-lang
Seich has joined #crystal-lang
maxpowa has joined #crystal-lang
fifr` has joined #crystal-lang
Xeago has joined #crystal-lang
astronavt has quit [Max SendQ exceeded]
libneko[m] has quit [Ping timeout: 258 seconds]
ProjectEpsilon has quit [Ping timeout: 258 seconds]
Liothen has quit [Ping timeout: 245 seconds]
chachasmooth has joined #crystal-lang
deavmi has joined #crystal-lang
avane has joined #crystal-lang
Vexatos has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
deavmi has quit [Ping timeout: 260 seconds]
<FromGitter> <BracketMaster> its definitely slower
<FromGitter> <BracketMaster> But I'm assuming M1 support is planned?
<straight-shoota> It's technically already supported. But there is an unrelated issue with LLVM 11 which prevents upgrading.
astronavt has joined #crystal-lang
deavmi has joined #crystal-lang
dostoyevsky has joined #crystal-lang
<FromGitter> <BracketMaster> well - I tried building it - I had to use Crystalx86 include in crystal sources - and it complained about linking arm64 code to x86 code
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Ping timeout: 252 seconds]
mipmip has joined #crystal-lang
DTZUZU has joined #crystal-lang
DTZUZU_ has quit [Ping timeout: 240 seconds]