ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.5 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
danielpclark has joined #crystal-lang
<FromGitter> <jwoertink> Does crystal support `catch / throw` like in Ruby? Or something similar?
<FromGitter> <Sija> yep, it does
<FromGitter> <jwoertink> I don't see `catch / throw` on there
<FromGitter> <jwoertink> Am I missing something?
<FromGitter> <Sija> sorry, i was thinking about `begin/rescue` (xx)
<FromGitter> <Sija> i think not
<FromGitter> <jwoertink> oh. Yeah, I know it has that. I'm looking for the actual `throw(:something); catch(:something)` syntax
<FromGitter> <jwoertink> thanks though
<FromGitter> <jwoertink> more specifically, I want to do something like this
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58927d5bdcb66e4f76dd1a1e]
<RX14> why can't you do that in the original signal handler block?
<FromGitter> <jwoertink> I might be able to, but right now I'm having trouble telling `Signal::INT.trap` to *not* exit
<FromGitter> <jwoertink> I want to catch it, but then do stuff and not exit the program
<FromGitter> <Sija> quick q: anyone knows if it’s possible to emulate ruby `send` method - possibly by using macros?
<FromGitter> <Sija> ```def [](option) ⏎ public_send(option) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=58928008d99b1dd03d322a04]
<FromGitter> <jwoertink> hmm... There's a `macro method_missing(call)`
<FromGitter> <drosehn> Keep in mind it would have to be done in a way which can be determined at compile time.
<FromGitter> <Sija> isn’t `method_missing` macro resolved at compile time?
<FromGitter> <jwoertink> yeah
<FromGitter> <jwoertink> I guess you would need something more at run time huh?
<FromGitter> <Sija> that would be great, but i don’t think it’s possible since compiler wouldn’t know the types… or is it?
<FromGitter> <jwoertink> Yeah, unless there was a way to just reference generic objects, but the generic type stuff is broken (I think)
<FromGitter> <Sija> other option is keeping a `Hash of String => AnyType` with `AnyType` being all the possible config values, which is ugly
<FromGitter> <jwoertink> lol
<FromGitter> <jwoertink> TYPE SET ALL THE THINGS!
<FromGitter> <Sija> :D
<FromGitter> <jwoertink> you'd need a macro that builds the world's largest union
<FromGitter> <jwoertink> alright, who wants to create the shard?
<FromGitter> <jwoertink> my_thing.as(AllTheThings)
<FromGitter> <Sija> .as(Object) would do ;)
<FromGitter> <drosehn> The few times I've used Object#send in ruby, it's to take an arbitrary method name which was determined at *runtime*, and call that method in some object. You can't really do that in crystal.
<FromGitter> <jwoertink> :joy:
<FromGitter> <Sija> one union of all types found in crystal src/, that would sth of compiler bug hunt 101
<FromGitter> <jwoertink> compiler bug hunt sounds like a game for Atari 2600
<FromGitter> <Sija> never had one, but could be one of these titles for programming nerd
<FromGitter> <Sija> z
<FromGitter> <jwoertink> :thumbsup:
<FromGitter> <Sija> possibly killing insects all over the logicboard
<FromGitter> <Sija> i think u could even mock it in sdl.cr ;)
<FromGitter> <jwoertink> yeah!
<FromGitter> <jwoertink> maybe I'll make that my demo game for my latest shard :D
<FromGitter> <jwoertink> ok, so I'm not sure what I'm missing here....
<FromGitter> <Sija> haha, ping me if u do ;)
<FromGitter> <jwoertink> ```Signal::INT.trap { ⏎ puts "Can't cancel" ⏎ }``` [https://gitter.im/crystal-lang/crystal?at=589283a45309d6b35898ce99]
<FromGitter> <jwoertink> I want this to do the puts, and then keep going... Any ideas how I can tell it to not exit?
<FromGitter> <Sija> i found no meaningful references to `Signal::INT` throughout the codebase, no idea :/
<FromGitter> <jwoertink> yeah, it's all in here, but it seems to call to some C stuff
<FromGitter> <Sija> hmm… i don’t see any call to exit on `INT`
<FromGitter> <jwoertink> yeah, I didn't either which was the weird thing
<FromGitter> <martinium> Is there a way to create immutable variables or data structures in Crystal?
<FromGitter> <Sija> @martinium no that i know of
<FromGitter> <martinium> They should differentiate a bit more from Ruby with like a let keyword to declare immutable variables.
<FromGitter> <martinium> Default of mutable variables would stay the same
<FromGitter> <jwoertink> wouldn't an immutable variable just be a constant?
<shelvacu> A const is just a var starting with a capital
<FromGitter> <martinium> Not necessarily
<FromGitter> <Sija> @martinium see https://github.com/crystal-lang/crystal/issues/1518
<FromGitter> <martinium> Const is checked at compile time
<FromGitter> <jwoertink> ah, I see
<FromGitter> <martinium> Immutable I think unchangeable from its creation
<FromGitter> <martinium> But they are very similar
<FromGitter> <martinium> They closed that request 11 months ago
<FromGitter> <martinium> IMO immutability is a big deal especially for languages that have parallelism baked in like this one will prior to 1.0
<FromGitter> <martinium> Swift is another lang that has both mutable and immutable variables and is quite fast just like this
<shelvacu> Well a struct would be an immutable variable, right?
<FromGitter> <martinium> The language Nim has all three. Mutable using var keyword, immutable using let keyword and compile time checked via const keyword
<FromGitter> <martinium> Depends on how crystal uses and defines struct
<FromGitter> <martinium> Struct to me is when you define your own data structure
<FromGitter> <martinium> Like in C
<shelvacu> I guess all Value objects
<FromGitter> <martinium> They can still change so a struct wouldn't be immutable by default. I could be wrong
<shelvacu> No wait, I don't know what I was thinking. Nevermind.
<FromGitter> <drosehn> Hmm. Looks like crystal's `Time` methods work at the millisecond level, while ruby's works at the microsecond level.
akwiatkowski has quit [Ping timeout: 240 seconds]
<FromGitter> <martinium> Hmm
<FromGitter> <martinium> That has to be fixed then
<FromGitter> <martinium> Probably Ruby's C implementation being badass as usual
<FromGitter> <martinium> Ruby ends up performing much more slowly though due to not being compiled
<FromGitter> <martinium> I wonder if they would ever just make a compiled ruby if it would causes a drastic speedup with minimal changes to the language
<FromGitter> <drosehn> It's hard to get a major speedup without making some significant changes to the ruby language. Some of the ruby scripts that I write *really* take advantage of the fact that so many things are determined at runtime.
Guest93652 has quit [Quit: Guest93652]
<FromGitter> <drosehn> I have been kind of surprised how much I take advantage of that when writing ruby scripts without really thinking about it.
greengriminal has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 264 seconds]
matp has quit [Remote host closed the connection]
<FromGitter> <andyfleming> There isn’t really any documentation of the docker container https://hub.docker.com/r/crystallang/crystal/
matp has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
balduin has quit [Ping timeout: 240 seconds]
<FromGitter> <martinium> this language needs a lot of new documentation by people who know the language up and down
greengriminal has quit [Quit: Leaving]
<FromGitter> <andyfleming> If I’m compiling on a mac, do I need to pass a param to create a binary for a linux machine?
matp has quit [Remote host closed the connection]
soveran has joined #crystal-lang
matp has joined #crystal-lang
<FromGitter> <andyfleming> (specifically looking to compile a binary for a container using scratch linux or alpine)
soveran has quit [Ping timeout: 248 seconds]
<FromGitter> <drosehn> I'm sure you do. I have no idea what it would be.
<FromGitter> <andyfleming> `crystal build src/example.cr --cross-compile --target "x86_64-unknown-linux-gnu”` looks like what I want
<FromGitter> <jwoertink> Is there anything like NodeJS EventEmitter for Crystal?
<FromGitter> <jwoertink> or is there a way to name a channel to be called somewhere else in an app?
<FromGitter> <raydf> @andyfleming, i use a virtualbox machine with linux for compiling from the app source code.
sz0 has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 245 seconds]
braidn_ has quit [Ping timeout: 264 seconds]
bmcginty has quit [Ping timeout: 264 seconds]
FromGitter has quit [Ping timeout: 264 seconds]
m94asr has quit [Ping timeout: 264 seconds]
miketheman has quit [Ping timeout: 264 seconds]
jsaak_ has quit [Ping timeout: 264 seconds]
FromGitter has joined #crystal-lang
shelvacu has quit [Ping timeout: 264 seconds]
shelvacu has joined #crystal-lang
jsaak has joined #crystal-lang
bmcginty has joined #crystal-lang
m94asr has joined #crystal-lang
miketheman has joined #crystal-lang
g3funk has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 260 seconds]
Raimondii is now known as Raimondi
Raimondi has quit [Ping timeout: 260 seconds]
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
bjz has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #3972: Fix self restriction with including generic module (master...fix/crystal/self-restriction) https://git.io/vDOop
<DeBot> https://github.com/crystal-lang/crystal/pull/3972 (Fix self restriction with including generic module)
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
mark_66 has joined #crystal-lang
soveran has joined #crystal-lang
matp has quit [Quit: ZZzzzZz...]
akwiatkowski has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 256 seconds]
gloscombe has joined #crystal-lang
Philpax has joined #crystal-lang
<FromGitter> <sdogruyol> @jwoertink crystalshards is your friend http://crystalshards.xyz/?filter=event :)
sz0 has quit [Quit: Connection closed for inactivity]
sz0 has joined #crystal-lang
Raimondi has joined #crystal-lang
<manveru> is there no multiline comment syntax? or even __END__ ? :)
<FromGitter> <Sija> @manveru nope :)
<manveru> ok
<FromGitter> <Sija> u can always open issue ‘bout that, I’d vote :+1: for `=begin/end` markers
<FromGitter> <Sija> in the meantime u might write a macro for that, sth like `comment do … end`
matp has joined #crystal-lang
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
<Yxhuvud> well you can usually use heredocs to the same effect, unless the comment is the last thing in a block.
<Yxhuvud> not the same thing as they won't end up in documentation, but may be good enough for some usages.
<FromGitter> <Sija> any1 knows a good way how to remove cyclic references from `Hash`?
<FromGitter> <Sija> https://carc.in/#/r/1lj9
balduin has joined #crystal-lang
matp_ has joined #crystal-lang
matp has quit [Ping timeout: 255 seconds]
sz0 has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<bmcginty> Sija: I've got something that's kind of modified and working... I'm probably commiting a code crime against types and who knows what else though.
<bmcginty> Sija: https://carc.in/#/r/1ljj
danielpclark has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> ugh does ZLib changed?
<FromGitter> <sdogruyol> I get a error on Crystal master while compiling Kemal ⏎ `undefined constant Zlib::Deflate`
<Yxhuvud> Hmm, might have been part of the zip changes, but that surprises me (and would force me to update one of my libs as well)
<FromGitter> <sdogruyol> yeah it's changed and a big one
<FromGitter> <sdogruyol> gonna update Kemal and feedback my results
<FromGitter> <martinium> Any Crystal lang enthusiasts in here in NYC?
mgarciaisaia has joined #crystal-lang
<Yxhuvud> The docs for Zlib::Deflate doesn't seem to be updated though
<FromGitter> <sdogruyol> yeah
<Yxhuvud> Ah, not in 0.20.5 yet, the commit is only 4 days old
mgarciaisaia has quit [Ping timeout: 240 seconds]
<FromGitter> <sdogruyol> so seems like initialize Flate::Writer.new with a block like i did with ⏎ ⏎ ```Zlib::Deflate.new(context.response) do |deflate| ⏎ IO.copy(file, deflate) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=589340561e4d4bd962c64646]
<FromGitter> <sdogruyol> //cc @asterite
mgarciaisaia has joined #crystal-lang
<FromGitter> <martinium> is ZLib for compressing files?
<FromGitter> <sdogruyol> yeah and also for compressing responses
<FromGitter> <sdogruyol> for HTTP servers
<FromGitter> <sdogruyol> Here's the difference to upgrade Kemal https://github.com/kemalcr/kemal/pull/304/files
<FromGitter> <thbar> Hi there! I'm playing around with Crystal, and trying to pass a `Class` as a method parameter then store that in an array inside the method (not an instance, a `Class` really). Is that supported ?
<FromGitter> <sdogruyol> @thbar yeah it's supported
<FromGitter> <sdogruyol> kinda hard to find from the docs though
<FromGitter> <sdogruyol> let me find an example
<FromGitter> <thbar> ah! thanks :-)
<FromGitter> <sdogruyol> forall T is what you need (as far as i know)
<FromGitter> <thbar> Woah there. Excellent, thanks !
<FromGitter> <sdogruyol> @thbar cheers and keep up the great work on Kiba :+1:
<FromGitter> <thbar> Thanks :-) I'm taking a bit of time today to figure out some Crystal bits that are required to port Kiba, indeed.
<FromGitter> <thbar> Glad you like it!
<FromGitter> <sdogruyol> It's great :fire:
<FromGitter> <Sija> @bmcginty thx! thing is: I want to use there plain Hash provided by the user without knowing its type beforehand
<FromGitter> <thbar> @sdogruyol you put me on the right track via "forall", and I finally found about class restrictions here https://crystal-lang.org/docs/syntax_and_semantics/type_restrictions.html#classes-as-restrictions
mgarciaisaia has quit [Ping timeout: 255 seconds]
<FromGitter> <sdogruyol> @thbar those are some great insights :)
<FromGitter> <sdogruyol> have you discovered method overloading yet <3 ?
<FromGitter> <sdogruyol> it's awesome
<FromGitter> <thbar> I think I'm right about to dive in, since I need some form of flexibility to allow passing both a block or a class type
<FromGitter> <thbar> Will look into it
mgarciaisaia has joined #crystal-lang
balduin has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <thbar> I'm trying to capture a block and store it as an instance variable, but I'm facing problems. First apparently since the block is not for immediate yielding but to be stored, I have to provide input and output types. But if I do so with e.g. `def transform(&block : Hash -> Hash)` then I get that `Hash` "cannot be used as a Proc argument type yet, use a more specific type". Is there a way to still capture a random block in a way or
<FromGitter> ... another?
<FromGitter> <thbar> Looking at it, thanks
<FromGitter> <jwoertink> Thanks @sdogruyol. I saw crystal has a built in class called Event as well, but I wasn't sure if that was the same or not
soveran_ has joined #crystal-lang
soveran has quit [Ping timeout: 252 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 260 seconds]
Raimondii is now known as Raimondi
<FromGitter> <Sija> @bmcginty finally! I’ve got some success with `Hash#merge`: https://carc.in/#/r/1lkb
matp_ has quit [Remote host closed the connection]
matp has joined #crystal-lang
fryguy9 has joined #crystal-lang
fryguy9 has quit [Client Quit]
mark_66 has quit [Remote host closed the connection]
DeBot has quit [Read error: Connection reset by peer]
DeBot has joined #crystal-lang
<FromGitter> <zatherz> is it possible to include a module in an enum?
<FromGitter> <Sija> @zatherz nope
<FromGitter> <zatherz> what about calling a macro?
<FromGitter> <zatherz> inside an enum body
<FromGitter> <Sija> macro yes
<FromGitter> <Sija> see https://carc.in/#/r/1lkl
DeBot has quit [Read error: Connection reset by peer]
<FromGitter> <zatherz> I mean calling a macro
<FromGitter> <zatherz> inside the body
DeBot has joined #crystal-lang
<FromGitter> <Sija> hmm, inside the enum’s body?
<FromGitter> <Sija> sth like ```
<FromGitter> <Sija> ```enum Foo ⏎ macro_magic A, B, C ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=58936f7adb9cafe9183eb717]
<FromGitter> <Sija> ?
<FromGitter> <Sija> AFAIK no, u could do the other way ‘round tho'
<FromGitter> <Sija> https://carc.in/#/r/1lky
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <zatherz> is there any way to strip the leading zero from floats?
<FromGitter> <zatherz> but only if it is a zero that's leading
<FromGitter> <zatherz> by any way I mean if there is any builtin to do that
<FromGitter> <zatherz> I'll just go with `result.to_i if result.to_i == result` if not
<FromGitter> <Sija> https://crystal-lang.org/api/0.20.5/String.html#to_f%28whitespace%3Dtrue%2Cstrict%3Dtrue%29-instance-method
<FromGitter> <zatherz> float -> string
<FromGitter> <zatherz> not the other way
<FromGitter> <martinium> are there any functional programming articles for Crystal?
<FromGitter> <zatherz> ```code paste, see link``` ⏎ ⏎ used this [https://gitter.im/crystal-lang/crystal?at=58937b1ce836bf7010c2cff3]
<FromGitter> <mverzilli> @martinium not that I know of. there's a quite interesting shard with immutable data structures: https://github.com/lucaong/immutable
<FromGitter> <martinium> hilarious
<FromGitter> <martinium> I was just asking about immutable variables yesterday
<FromGitter> <martinium> that they should be added via a let keyword etc so crystal could adopt FP features that would be quite beneficial
<RX14> i think that adding such features dilutes the language quite a bit
<RX14> it feels like just "adding FP for FP's sake"
<FromGitter> <martinium> why do you think it dilutes?
<RX14> because it doesn't really fit with the rest of the language
<RX14> crystal is OO and mutable
<FromGitter> <martinium> The only reason I think immutable variables would be awesome is due to managing state more effectively
<FromGitter> <martinium> Nim is Imperative and OO but supports mutable and immutable
<RX14> mutability scales inside a method, but not inside a whole codebase
<RX14> variables themselves being immutable is pointless if the objects are not immutable
<RX14> and immutable objects can easilly be created using crystal
<FromGitter> <martinium> well yes immutable variables objects etc
<FromGitter> <martinium> via use of let keyword
<FromGitter> <martinium> or whatever they choose to adopt
<RX14> no, inventing "let" wouldn't magically make the underlyingf object immutable
<RX14> immutability is a property of an object not a reference
<RX14> creating the arbitrary "this variable cannot be assigned to" seems moot when your method fits on the screen
<FromGitter> <martinium> I mean immutable the way Rust-lang does it
<RX14> what does not fit on the screen is your entrie codebase
<FromGitter> <martinium> via their let keyword
<RX14> and your objects *are* passed around the entire codebase
<RX14> making them immutable is the solution, not making variables immutable
<FromGitter> <martinium> yeah I understand and kind of what I meant
<FromGitter> <martinium> support making objects variables functions immutable
<RX14> @martinium the correct way to write immutable objects is to just write immutable objects
<FromGitter> <martinium> while still allowing for mutable versions
<RX14> i don't feel syntax support is worthwhile
<RX14> that sounds impossible to me
<RX14> at least with crystal's level of introspection
<FromGitter> <martinium> it may not even be necessary since the syntax is so clean already
<FromGitter> <martinium> the compiler also helps so we will see if long term people can avoid huge bugs in big projects
<RX14> in rust methods specify whether they can modify the object they're called on, right?
<RX14> in crystal that's just not there so it's not possible to just "turn on and off" immutability
<FromGitter> <martinium> yeah
<FromGitter> <martinium> everything in rust is immutable by default
<FromGitter> <martinium> you make them mutable by using the word mut
<RX14> rust is very much safetey is key
<RX14> which has a place
<FromGitter> <martinium> yep
<RX14> but I think crystal has a more balanced view
<FromGitter> <martinium> Crystal is more dynamic and freeing
<FromGitter> <martinium> so I can see the style differences
<RX14> and is more productive because of that
<FromGitter> <zatherz> is there a builtin to do something like this? ⏎ ⏎ ```[1, 2, 3, 4, 5].the_method(3) #=> [[1, 2, 3], [4, 5]] ⏎ [1, 2].the_method(3) #=> [[1, 2]]``` [https://gitter.im/crystal-lang/crystal?at=58938400e836bf7010c31401]
<RX14> yes
<FromGitter> <zatherz> and how is it called?
<RX14> can't remember
<RX14> each_slice
<RX14> @zatherz https://crystal-lang.org/api/0.20.5/Enumerable.html#each_slice%28count%3AInt%2Creuse%3Dfalse%2C%26block%29-instance-method
<FromGitter> <martinium> nice
<FromGitter> <martinium> @RX14 you work as a professional programmer aka your day job?
<FromGitter> <zatherz> nice, thanks
<RX14> @martinium no, i'm a student
<FromGitter> <martinium> CS?
<RX14> CS, maths and physics
<FromGitter> <martinium> nice
soveran_ has quit [Remote host closed the connection]
mgarciaisaia has quit [Ping timeout: 276 seconds]
mgarciaisaia has joined #crystal-lang
soveran has joined #crystal-lang
bjz has joined #crystal-lang
<FromGitter> <martinium> is there a way using the error handling to retry a section of your program until the expected input is entered?
<FromGitter> <martinium> Would I have to use the exception handling?
<FromGitter> <martinium> for instance if a user enters a string value instead of an integer value, instead of erroring and stopping the program I would want it to repeat the same prompt
<FromGitter> <martinium> yes just like that
<FromGitter> <martinium> is that feature still missing from crystal per that issue?
<FromGitter> <Sija> depending what do you mean by “missing from crystal"
<FromGitter> <martinium> am I able to use that functionality in the current Crystal version
pawnbox has joined #crystal-lang
<FromGitter> <Sija> there’s a method which does the job, but not a keyword if u mean that - see https://github.com/crystal-lang/crystal/issues/1736#issuecomment-241382286
<FromGitter> <Sija> i meant, there’s a way to implement it as a regular method
<FromGitter> <thbar> What is the correct syntax to set a default value "empty hash" to a method parameter? I tried `def initialize(klass : T, block : (Row -> Row) | Nil, options : {} of Symbol => String)` but I get the error `expecting token 'CONST', not '}'`. Thanks!
<RX14> default value uses =
<RX14> setting the type uses :
<RX14> type restriction*
<FromGitter> <thbar> Ahhh! Found it, right ; it's my ":" instead of "="
<FromGitter> <thbar> Indeed
<RX14> may I ask where options comes from?
<FromGitter> <thbar> I'm playing around to write a Crystal prototype of my ETL library http://www.kiba-etl.org/, and typically the options are generic options to initialize components, provided by the developer.
<FromGitter> <thbar> e.g. for a `CSVSource` which will yield CSV rows one by one, the options could be: `{filename: "the_file.csv"}`.
<RX14> I'm just wondering if named parameters be more appropriate
<FromGitter> <thbar> I have no idea at this point, but I will try out various approaches (tuple etc, named parameters etc)
<RX14> if these fit the job, they're much more flexible than hashes or named tuples
<FromGitter> <thbar> I have tried but did not manage to get that so far, maybe because I need arbitrary names for the keys etc. I will try again once I have a basic prototype working. Thanks!
<RX14> you'd probably want **args for that, but that's something to think about once it works for sure!
<FromGitter> <thbar> Hehe yes :-)
<FromGitter> <thbar> Thanks for your input !
undying has joined #crystal-lang
undying has quit [Quit: Page closed]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
undying has joined #crystal-lang
undying has quit [Client Quit]
undying has joined #crystal-lang
undy1ng has joined #crystal-lang
<crystal-gh> [crystal] spalladino opened pull request #3984: Updated contributing guidelines (master...doc/contributing) https://git.io/vDs2L
<DeBot> https://github.com/crystal-lang/crystal/pull/3984 (Updated contributing guidelines)
undying has quit [Client Quit]
mgarciaisaia has quit [Ping timeout: 255 seconds]
gloscombe has quit [Quit: Lost terminal]
pawnbox has quit [Remote host closed the connection]
soveran has quit [Remote host closed the connection]
<crystal-gh> [crystal] ysbaddaden opened pull request #3985: OpenSSL server socket fixes (master...std-openssl-fixes) https://git.io/vDsoh
<DeBot> https://github.com/crystal-lang/crystal/pull/3985 (OpenSSL server socket fixes)
<crystal-gh> [crystal] ysbaddaden opened pull request #3986: AlpineLinux and musl-libc fixes (master...core-iconv-musl-libc) https://git.io/vDsKr
<DeBot> https://github.com/crystal-lang/crystal/pull/3986 (AlpineLinux and musl-libc fixes)
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
<FromGitter> <thbar> I'm trying to use Hash with a union type for the values, in order to provide flexible configuration. As soon as I add more than 1 type to the union, though, I get this error https://gist.github.com/thbar/92c2deaa5422b6fccb98a1132c333882 . Is there a way to make this work?
<RX14> @thbar the type of c will be String | Int32
<RX14> so passing it to the constructor will fail because @filename needs to be a string
<RX14> there's a few ways to fix it
<RX14> you could use .as(String) on c
<RX14> and it'll just raise
<RX14> but a better way would be to used a namedtuple
<RX14> or some other type which plays better with the type system
<FromGitter> <thbar> I'm going to have other components like `SomeSource`, all with options named differently. I am under the impression that I can't use NamedTuple for that case, is that right?
<FromGitter> <thbar> (options named differently = with various keys, which are component specific)
<FromGitter> <thbar> I have an upper layer storing these hashes, then later instantiating each component (like `SomeSource`) by passing the options down there
<FromGitter> <thbar> I'll try on a small test case with named tuples, but so far I have the impression that the keys are mixed between the components, as I assume maybe the names of the keys are shared etc. But well this is still new, so I'll try again later. Thanks!
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 260 seconds]
<FromGitter> <andyfleming> Any idea why a crystal binary compiled in ubuntu wouldn’t run in a scratch/alpine docker container?
<RX14> @andyfleming different libc
<RX14> alpine uses musl libc
pawnbox has joined #crystal-lang
<FromGitter> <andyfleming> Any idea on the leanest container that works for a crystal binary? I was able to make `debian:jessie-slim` work after installing `libssl1.0.0 libssl-dev` at about 119 MB
pawnbox has quit [Ping timeout: 240 seconds]
<FromGitter> <jots_twitter> @thbar : kiba looks super interesting, hope to try it out in the next few days and would be interested in how your crystal port goes.
<FromGitter> <andyfleming> And actually it looks like I may be able to exclude libssl-dev and get it down to 97.1 MB
<RX14> @andyfleming crystal will work on alpine you just need an existing container
<RX14> and build the binary in the aslpine container
<FromGitter> <andyfleming> I was using `docker run -w /app -v $(pwd):/app crystallang/crystal crystal build src/service.cr --release -o service-release` for simplicity
<RX14> but crystallang/crystal isn't alpine
<FromGitter> <andyfleming> Yeah, I wasn’t sure about the compatibility side until you mentioned the libc difference
<FromGitter> <andyfleming> That would be awesome if you updated your alpine-crystal docs :)
<RX14> yeah hmm
<FromGitter> <andyfleming> Would I be able to use that container to compile as well?
<RX14> yep
<RX14> you have to lol
<FromGitter> <andyfleming> Awesome
<RX14> i mean the containers were still 62MB
<FromGitter> <andyfleming> I figured I still had to compile in alpine somewhere. Just wasn’t sure if the strategy is to use the same one or not.
<FromGitter> <andyfleming> You are happy or unhappy with 62MB?
<RX14> unhappy
<RX14> alpine base is much smaller
<FromGitter> <andyfleming> We should have a separate alpine-crystal-compiler and alpine-crystal
<FromGitter> <andyfleming> Then we could get the size of alpine-crystal down, right?
<RX14> maybe
<RX14> probably not by much
<FromGitter> <andyfleming> Forgive my ignorance, but is the crystal compiler a single binary? or does it have external dependnecies?
<RX14> well it's dynamically linked
pawnbox has joined #crystal-lang
danielpclark has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]