ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7f06 can you double escape a macro?
alex`` has quit [Ping timeout: 248 seconds]
<FromGitter> <Blacksmoke16> omg nvm im an idito
<FromGitter> <Blacksmoke16> the ivar method doesnt work outside of a method
_whitelogger has joined #crystal-lang
chemist69 has quit [Ping timeout: 252 seconds]
chemist69 has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <sam0x17> people who are familiar with the compiler: what would the feasibility be of making something like ccache to optimization repeated compilation of a largely unchanged code base? (ccache is a program that you use as an alias for gcc/g++ that caches .o files based on source file hashes, and can greatly speed up large c/c++ build environments)
<FromGitter> <sam0x17> *optimize
<FromGitter> <sam0x17> in other words, you be like "g++ something.c -o something" and ccache be like "oh, you haven't changed something.c, here's what you compiled before"
<FromGitter> <sam0x17> (oversimplification, but demonstrates the concept)
<FromGitter> <sam0x17> I'm guessing the answer is something like "blah blah multipass blah blah llvm blah blah so no" xD
<FromGitter> <absolutejam_gitlab> is there a way for a method to accept any object that implements an interface?
<FromGitter> <sam0x17> @absolutejam_gitlab so at least implicitly I know the answer is yes --- you can just not specify the type, and start using methods you would expect to exist on that interface, and each method call you make narrows the possible objects the compiler will let through there
<FromGitter> <absolutejam_gitlab> Ah, so if I just call the method
<FromGitter> <absolutejam_gitlab> Is there a `has_method?` or the likes?
<FromGitter> <absolutejam_gitlab> I guess you could add it via. macro on `Object`...
<FromGitter> <absolutejam_gitlab> fair enough
<FromGitter> <sam0x17> see `method_missing` in here: https://crystal-lang.org/reference/syntax_and_semantics/macros/hooks.html
<FromGitter> <sam0x17> or no
<FromGitter> <sam0x17> sorry that's the opposite of what you want
<FromGitter> <sam0x17> ^ but very useful
<FromGitter> <sam0x17> you might be able to make use of `obj.is_a?(Klass)` -- not sure if it works for interfaces tho
<FromGitter> <waghanza> Hi, I have static compilation issue in https://github.com/the-benchmarker/web-frameworks/pull/1578#issuecomment-522216109
<FromGitter> <waghanza> for `onyx` and `spider-gazelle`, but I have not this issue for `amber` (for example)
<FromGitter> <waghanza> has anyone experienced a portable binary creation ?
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 272 seconds]
sagax has quit [Remote host closed the connection]
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<FromGitter> <j8r> @waghanza your Dockerfile is strange
<FromGitter> <j8r> usually we build statically on Alpine, then putting on an image `from scratch`
<FromGitter> <j8r> not building on Ubuntu statically to put in Alpine
<FromGitter> <asterite> Sam Johnson: the compiler already caches obj files to avoid compiling llmv bc files into o files if they didn't change. It's just that the semantic phase of the compiler, and emittimg llmv ir, is always done because it's pretty hard to figure out whether a file. really changed or not (some code can be different based on a macro call defined on a separate file, for example, but there are many other such
<FromGitter> ... examples)
<FromGitter> <asterite> James Booth: for interfaces use modules
<FromGitter> <j8r> @waghanza you can take a look at https://github.com/j8r/dockerfiles/tree/master/crystal-alpine. ⏎ You don't need to use this image, but you can take inspiration to build your own
<FromGitter> <j8r> only Alpine is truly supported for static compilation, other OSes might work but it isn't garanted
<FromGitter> <bew> Where is the dockerfile for the crystallang/crystal image? I don't see it in the crystal repo
<FromGitter> <bew> thanks, but I'm looking for a github link, to find the history of that file
<FromGitter> <absolutejam_gitlab> @asterite yeah, thanks. I saw the use of modules to provide the 'contract' but it was just detection at the
<FromGitter> <absolutejam_gitlab> Receiving func
<FromGitter> <tenebrousedge> @bew https://github.com/crystal-lang/crystal/pull/6141
<FromGitter> <absolutejam_gitlab> But I didn't think of the simplest solution that @sam0x17 said which is to just call the method and the compiler
<FromGitter> <absolutejam_gitlab> Let the compiler catch it *
<FromGitter> <absolutejam_gitlab> But I guess if I was aiming for 'anything that implements this interface', I'd still have to narrow the scope?
<FromGitter> <absolutejam_gitlab> Like I couldn't accept object because it would expec all objects to implement it?
<FromGitter> <tenebrousedge> @bew so it used to be part of crystal-lang/crystal and is now part of /distribution-scripts, so depending on what you're after it may be in two places
<FromGitter> <kingsleyh> hi -I've got an Array(T) which i want to convert to and from json - where either A or B extends from T - what is the best way to implement the json serialisation? is it to create to_json and from_json in the abstract class T ? or in each of the A and B that extends from T
<FromGitter> <j8r> @sam0x17 A thing I don't like with your images is there is no source
<FromGitter> <j8r> we don't know the source Dockerfile
<FromGitter> <tenebrousedge> @kingsleyh you could put it in the abstract class I suppose? Your other option would be to make a module
<FromGitter> <kingsleyh> hmm I put a JSON.mapping in both A and B - so I guess the issue is more with T
<FromGitter> <kingsleyh> what is the best paste bin site to use for Crystal?
<FromGitter> <kingsleyh> ah nevermind play is good
<FromGitter> <kingsleyh> can someone help me with this?
devil_tux has joined #crystal-lang
<FromGitter> <tenebrousedge> what is `Q.from_json` supposed to do?
<FromGitter> <tenebrousedge> oh, nvm
<FromGitter> <bew> @kingsleyh can you give us the output with `--error-trace` ?
<FromGitter> <bew> (note: that should be the default in play/carc.in)
<FromGitter> <bew> (I'll open an issue to fix that)
<FromGitter> <kingsleyh> @bew I edited it: https://play.crystal-lang.org/#/r/7f22
<FromGitter> <asterite> @kingsleyh there's no way to do what you want if both A and B inherit from the same type
<FromGitter> <kingsleyh> oh i se
<FromGitter> <asterite> you could try defining `M.from_json` that tries to decode from B first, and if that fails it decodes from A
<FromGitter> <asterite> but you have to do it manually... or maybe you can use `subclasses` macro, but I wouldn't go that route (it won't work if eventually you introduce generics)
<FromGitter> <kingsleyh> the only reason for the abstract class is to share some code that both A and B need - but I could flip it over and have A and B include the shared code from a module
<FromGitter> <kingsleyh> would that work?
<FromGitter> <asterite> it would work if you use a module and then you do `Array(A | B)`, I think
<FromGitter> <asterite> it won't work if you do `Array(M)` and M is a module
<FromGitter> <kingsleyh> ok got it working thanks :)
<FromGitter> <Blacksmoke16> @absolutejam_gitlab use a module or abstract parent class as the type restriction?
<FromGitter> <bew> How can I make a spec that passes when an array has at least some elements? (I know it's a code smell, but I need this kind of spec for now)
<FromGitter> <Blacksmoke16> `arr.should_not be_empty`
<FromGitter> <bew> more like `arr.should have_at_least([1, 2])`, where I specify the elements
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7f26
<FromGitter> <Blacksmoke16> possibly `#contain` could be updated to support multiple values to check against?
<FromGitter> <bew> hmm yes that would be nice, thanks for the input, I'll figure sth out based on this
devil_tux has quit [Ping timeout: 244 seconds]
<FromGitter> <j8r> mps have you the ability to review and merge aports?
<mps_> j8r: yes, but not for main subdir
<mps_> which one, do you have url
<mps_> I can look
<mps_> kingsleyh: yes, I have it
<FromGitter> <kingsleyh> great - I'll have a read then
devil_tux has joined #crystal-lang
<FromGitter> <j8r> that's was in main :/
<mps_> it doesn't cost too much, and is fine to read it on tablet in the garden or coffee shop, bus or similar places
<FromGitter> <kingsleyh> I've bought the kindle edition
<mps_> kingsleyh: most of material in book you can find on the net but it is fine to have them in one file/book
<mps_> and the interviews are interesting, especially with bararchy
<FromGitter> <kingsleyh> ah yes Neuralegion - I'm working with those guys
<FromGitter> <kingsleyh> using their Nexploit and bararchy is on my project as an advisor - great guy - great company
<mps_> hm, looks like half of people here works with NeuraLegion :-)
<FromGitter> <kingsleyh> well everyone needs security :)
devil_tux has quit [Ping timeout: 245 seconds]
<mps_> j8r: why do you need libstdc++-dev
<mps_> ah, you want static lib?
<FromGitter> <j8r> only, yes
<FromGitter> <j8r> it will result on smaller Docker images
<FromGitter> <j8r> but don't know why I can't build, even without my patch
lucasb has joined #crystal-lang
<mps_> j8r: j8r: I don't like to mess with a big packages (as is this one) and prefer to left to the maintainer to decide
<mps_> I tried build your changes for curl, it builds but I'm not sure we should nghttp2
<mps_> s/should/should disable/
sagax has joined #crystal-lang
<FromGitter> <Blacksmoke16> can you not link to a parent's initialize in a child
<FromGitter> <Blacksmoke16> `Parent#new`
<FromGitter> <Blacksmoke16> (for generating links in the docs)
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d5818e17d56bc60806faaa6]
<FromGitter> <Blacksmoke16> none of these seem to work
go|dfish has quit [Ping timeout: 258 seconds]
devil_tux has joined #crystal-lang
<FromGitter> <j8r> ok, thanks mps_. That's because otherwise we can't link statically
<mps_> j8r: understand, but then nghttp2 should be fixed
<mps_> may I suggest you to join #alpine-linux and ask there, you will probably get more answers and ideas
<FromGitter> <j8r> mps_ yes, I've tried everything and noway
<FromGitter> <j8r> this isn't related to the package nghttp2, but how compiling curl
<FromGitter> <j8r> mps_ done
<FromGitter> <j8r> with kiwi irc web client
<FromGitter> <j8r> quite nice
<FromGitter> <j8r> for those interested, I have added new tags for jrei/crystal-alpine https://cloud.docker.com/repository/docker/jrei/crystal-alpine/tags
return0e has quit [Ping timeout: 248 seconds]
return0e has joined #crystal-lang
go|dfish has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 245 seconds]
Raimondii is now known as Raimondi
devil_tux has quit [Ping timeout: 246 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 258 seconds]
Raimondii is now known as Raimondi
rohitpaulk has joined #crystal-lang
ht__ has joined #crystal-lang
ht_ has quit [Ping timeout: 252 seconds]
ht__ is now known as ht_
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> any idea wtf is doing on here? https://play.crystal-lang.org/#/r/7f3x ⏎ mainly why does each assertion get printed three times, with the same annotation on the same ivar?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7f45 reduced a bit more
<FromGitter> <Blacksmoke16> ill make an issue for it
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
lvmbdv has quit [Ping timeout: 245 seconds]
lvmbdv has joined #crystal-lang
Groogy has joined #crystal-lang
lvmbdv has quit [Ping timeout: 272 seconds]
lvmbdv has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 258 seconds]
<FromGitter> <watzon> Is there no easy way to make `HTTP::Headers` from a Hash or NamedTuple?
<FromGitter> <watzon> runtime value
<FromGitter> <watzon> @tenebrousedge tried that, there isn't an overload that works with NamedTuples apparently
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d5866e97d56bc6080721954]
<FromGitter> <tenebrousedge> hmm. Do you feel like extending the Header class?
<FromGitter> <watzon> I'd rather not monkeypatch if I can avoid it
<FromGitter> <watzon> I'll try the `.each` method
<oprypin> watzon, that error is coming from the implementation of `def ==` - something's off
ht_ has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> @watzon could just new up on, then iterate over your hash using .each then do `headers.add`
<FromGitter> <Blacksmoke16> maybe could make an issue about it
sagax has quit [Remote host closed the connection]
<FromGitter> <tenebrousedge> `hash.each_with_object(Header.new) do { |(k, v), h| h.add(k,v) }`
<FromGitter> <fenicks> I'm trying to cross compile a crystal program for arm architecture ⏎ The devixe is a RockPro64 running Ubuntu 18.04 ⏎ When trying this command line: `crystal build src/cli/main.cr --release --cross-compile --target arm-unknown-linux-gnueabihf` and execute the printed line, I have this error: `wrong format`. ⏎ ⏎ How can i fix this ? ... [https://gitter.im/crystal
<FromGitter> ... -lang/crystal?at=5d5878e3d03a7c63e648ea9b]
<FromGitter> <Blacksmoke16> :shrug:
gangstacat has quit [Quit: Ĝis!]
sagax has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <j8r> @fenicks try aarch64 instead of armhf