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
<JJEE> or can we just export single functions/methods, classes, etc.
<FromGitter> <Blacksmoke16> do you actually mean `module` or a shard/file?
<JJEE> ehm
<JJEE> inside of a file
<JJEE> `module Xxxx`
<JJEE> that's not required right ?
<FromGitter> <Blacksmoke16> no it is, a module is not like JS
<FromGitter> <Blacksmoke16> you require files, not specific elements in the file
<JJEE> i understand that, but we do not have to use `module` inside of the file right
<JJEE> it can be a class too, for example?
<FromGitter> <Blacksmoke16> if you want to define a class yes
<FromGitter> <Blacksmoke16> but if you want to define a module ofc you have to use `module`
<JJEE> i see, that makes sense, thanks for telling me
<FromGitter> <Blacksmoke16> you can also do like: ⏎ ⏎ ```class Foo ⏎ record Bar ⏎ end ⏎ ⏎ pp Foo::Bar.new``` [https://gitter.im/crystal-lang/crystal?at=608c9b8fd964ec5538812e9b]
<FromGitter> <Blacksmoke16> it is advised to namespace all your code however. To avoid name conflicts and such
<JJEE> what about calling the class as a function
<FromGitter> <Blacksmoke16> thats not a thing, would need to define a method
<FromGitter> <Blacksmoke16> e.g.
<JJEE> (inside of the class?)
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=608c9d212cc8c84d85023800]
<FromGitter> <Blacksmoke16> or could also make it an instance method depending on what exactly you're wanting
<JJEE> I see
JJEE has quit [Quit: The Lounge - https://thelounge.chat]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
chachasmooth has quit [Ping timeout: 276 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 265 seconds]
chachasmooth has joined #crystal-lang
notsogreatl has joined #crystal-lang
<notsogreatl> is there any way to get the executable name in crystal? i tried ARGV[0] but nope
Dreamer3 has joined #crystal-lang
notsogreatl has quit [Quit: The Lounge - https://thelounge.chat]
Dreamer3 has quit [Quit: Leaving...]
deavmi has quit [*.net *.split]
astronavt has quit [*.net *.split]
coderobe has quit [*.net *.split]
bazaar has quit [*.net *.split]
astronavt has joined #crystal-lang
coderobe has joined #crystal-lang
deavmi has joined #crystal-lang
andremedeiros has joined #crystal-lang
andremedeiros has quit [Client Quit]
andremedeiros has joined #crystal-lang
<FromGitter> <spTorin> ```puts PROGRAM_NAME ⏎ puts File.dirname(File.real_path(PROGRAM_NAME))``` [https://gitter.im/crystal-lang/crystal?at=608cf746d261cc4d749f1256]
HumanG33k has joined #crystal-lang
hendursaga has joined #crystal-lang
hendursa1 has quit [Ping timeout: 240 seconds]
_ht has joined #crystal-lang
xybre has quit [*.net *.split]
xybre has joined #crystal-lang
<FromGitter> <drum445> How do I splat an array? It says I need to convert it to a tuple first
<FromGitter> <drum445> `*params`
<jhass> Yes you need to because only with tuples the size and types are known at compile time
<jhass> Tuple#from is there to help you
<jhass> some_method(*{String, Int32}.from(params))
<FromGitter> <drum445> The amount in the array could differ though
<jhass> then you can't
<jhass> how would the compiler know what call to generate if the size is only known after the fact :)
yxhuvud has quit [Remote host closed the connection]
<FromGitter> <drum445> the problem I've got (and something I've managed to achieve in every other language), is I want to send a list of params through to db.exec(query, params)
<FromGitter> <drum445> it doesn't seem to like an array and in Ruby I simply splat the params through
<FromGitter> <drum445> how can I get around this?
<jhass> why's it an array in the first place?
<FromGitter> <drum445> because it's a generic update method in my DAL
<jhass> why can't that generic method not take a tuple?
<FromGitter> <drum445> because it accepts a hash then params is the hash.values
<FromGitter> <drum445> let me try another way
<FromGitter> <drum445> `@db.exec(qry, args: params)` looks to do the trick
<jhass> We got NamedTuple#values returning a tuple
<jhass> anyhow it looks like exec does take an array, it just needs to be named: https://github.com/crystal-lang/crystal-db/blob/master/src/db/query_methods.cr#L274
<jhass> .exec(query, args: params)
yxhuvud has joined #crystal-lang
<FromGitter> <drum445> cheers 👍
yxhuvud has quit [Remote host closed the connection]
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #crystal-lang
<FromGitter> <kingsleyh> afternoon - can anyone suggest a nice way to do this merge of hashes with arrays? https://play.crystal-lang.org/#/r/b1i0
<FromGitter> <Blacksmoke16> not as simple as that afaik
<FromGitter> <Blacksmoke16> given its more of a combine + dedup
<FromGitter> <error256> `a.merge(b){ |_, xs, ys| (xs + ys).uniq! }`?
<FromGitter> <Blacksmoke16> 👍 TIL there's a block version of merge
<FromGitter> <Blacksmoke16> prob could use `.merge!` to not create a new hash if you dont care it would modify `a`
<FromGitter> <kingsleyh> Nice!
<FromGitter> <kingsleyh> Also TIL TIL
<FromGitter> <rsk700> can someone give me example of Symbol usage, docs describe it, but there is no example why you will need it ⏎ https://crystal-lang.org/api/1.0.0/Symbol.html
<FromGitter> <Blacksmoke16> imo only time they're useful is autocasting to an Enum member
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
sagax has joined #crystal-lang
deavmi has quit [Read error: No route to host]
deavmi has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> @Blacksmoke16: i would not say that symbols are involved in that situation at all
<FromGitter> <Blacksmoke16> technically not i guess but the syntax is
jhass has quit [Quit: Bye]
jhass has joined #crystal-lang
asterite has quit [Ping timeout: 258 seconds]
DeBot has quit [Ping timeout: 258 seconds]
asterite has joined #crystal-lang
ua has quit [Ping timeout: 252 seconds]
ua has joined #crystal-lang
asterite has quit [Quit: Bye]
asterite has joined #crystal-lang
yxhuvud has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
asterite has quit [Quit: Bye]
asterite has joined #crystal-lang
_ht has quit [Remote host closed the connection]
r0bby has quit [Ping timeout: 250 seconds]
r0bby has joined #crystal-lang
r0bby has quit [Max SendQ exceeded]
r0bby has joined #crystal-lang
r0bby has quit [Excess Flood]
r0bby has joined #crystal-lang
<straight-shoota> @rsk700: Did you only look at the API docs? Symbols are a language feature and the language reference has some more info on them: https://crystal-lang.org/reference/syntax_and_semantics/literals/symbol.html
<straight-shoota> Basically, it's a unique value in the program and you would usually use it to signal some kind of unique status.
<FromGitter> <grkek> Does anyone have a binding for a performant HTTP request parser, preferably written in C?
<straight-shoota> It's a rather controversial feature, inherited from Ruby. Many people don't use symbols at all. Unless you're really intrigued about them, you don't really need to bother.
<FromGitter> <grkek> I use symbols and they are very comfy
<straight-shoota> @grkek, IMHO, Crystal's native request parser is pretty performant
<FromGitter> <grkek> I want it to be on par with the H2O.cr performance
<FromGitter> <jrei:matrix.org> h2O too slow?
<FromGitter> <grkek> H2O is way too fast
<FromGitter> <jrei:matrix.org> the stdlib parser does not fit your use case, why?
<FromGitter> <grkek> I want it to be extra fast
<FromGitter> <jrei:matrix.org> ok... who knows...
<FromGitter> <jrei:matrix.org> you may have similar or better speed, even with slower parsers, if you use them wisely
<FromGitter> <jrei:matrix.org> for instance, parallelization
<straight-shoota> what's the perf difference between h2o and HTTP::Request?
<FromGitter> <jrei:matrix.org> and it is not even sure it will matters. The slow part may be somewhere else
<FromGitter> <jrei:matrix.org> in your app
<FromGitter> <grkek> https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=plaintext&l=zdk8an-sf
<FromGitter> <jrei:matrix.org> ok but we are talking about a real world app
<FromGitter> <grkek> I am talking about a simple benchmark
<FromGitter> <jrei:matrix.org> maybe I'm wrong, your app may be only about parsing HTTP request like this benchmark?
<FromGitter> <grkek> here take a look at what this benchmark really does
<FromGitter> <jrei:matrix.org> hellow world...
<FromGitter> <jrei:matrix.org> yeah ok, unlikely a real world app will look like this
<straight-shoota> It seems this benchmark isn't about just parsing requests but also includes routing and other server components
<FromGitter> <jrei:matrix.org> you need better perf for your framework?
<FromGitter> <jrei:matrix.org> yeah, so it will be just a fraction of the time
<FromGitter> <grkek> No I just want a binding which is as fire as pico.v
<FromGitter> <grkek> https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=plaintext
<FromGitter> <grkek> Literally bent every other framework
<FromGitter> <grkek> I was trying to write bindings for picoev but I was facing issues
<FromGitter> <fatherofinvention> When I run that example I get a positive value when the left operand is larger and a negative value when it is smaller.
<FromGitter> <grkek> https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=json&l=zdk8an-sf
<FromGitter> <oprypin:matrix.org> @fatherofinvention: yes that is a mistake in the description. please report it or make a pull request directly
<FromGitter> <oprypin:matrix.org> > rewrite `a < b` as `(a <=> b) < 0`
<FromGitter> <oprypin:matrix.org> basically `result [op] 0` will match `a [op] b` for `op` in `<` `==` `>` etc
Liothen_ has joined #crystal-lang
Liothen has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> j8r (https://matrix.to/#/@jrei:matrix.org): I used your gist to build an aarch64 docker image, thanks! ⏎ I didn't know about qemu-user-static, that's awesome
<FromGitter> <erdnaxeli:cervoi.se> what is the status about https://github.com/crystal-lang/crystal/issues/5467 ?
<FromGitter> <erdnaxeli:cervoi.se> because of the missing target for armhf I have to use debian as the base docker image, which adds 25Mo
<FromGitter> <erdnaxeli:cervoi.se> (I mean armhf + musl)