<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>
<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>
<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?
<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)
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>
<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