<FromGitter>
<respitesage:matrix.org> Ah, so that's the problem in your code. Mine is just a language semantics thing, I guess.
<FromGitter>
<Blacksmoke16> are class methods not inherited?
<FromGitter>
<Blacksmoke16> > A class inherits all instance variables and all instance and class methods of a superclass, including its constructors (new and initialize). ⏎ ⏎ seems they should
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
<FromGitter>
<didactic-drunk> I can't delete `*`. It's valid crystal and lets you require named arguments.
<FromGitter>
<didactic-drunk> Shouldn't there be a way to easily generate either the method definition or arguments as is for use in macro redefinition? Maybe `def.def` `def.redef` `def.args.def`
<FromGitter>
<HertzDevil> `InnerClass` must also be a generic
notzmv has quit [Ping timeout: 265 seconds]
ur5us has joined #crystal-lang
Guest9910 has joined #crystal-lang
Guest9910 has quit [Client Quit]
ur5us has quit [Ping timeout: 255 seconds]
<FromGitter>
<alexherbo2> how about adding `path.match?(pattern)` to wrap around `File.match?(pattern, path)`? https://crystal-lang.org/api/1.0.0/File.html#match?(pattern:String,path:Path%7CString)-class-method
notzmv has joined #crystal-lang
<FromGitter>
<asterite> Yes, I thought many times of adding a `signature` method to the `Def` AST node
elf_fortrez has joined #crystal-lang
<mfiano>
Hi again. I spent the last couple days reading the language reference and stdlib api docs. I think I could really become comfortable with this as a secondary language.
<FromGitter>
<alexherbo2> how to get the mime type from a file content?
<FromGitter>
<Blacksmoke16> mfiano glad to hear
<FromGitter>
<Blacksmoke16> @alexherbo2 there's a `MIME` module you can use to get it from the filename/ext
<FromGitter>
<Blacksmoke16> but there isn't a method to do that based on content
<mfiano>
Thanks, it really is nice, and seems to borrow a lot from my primary language, yet seems to check off the items I'm looking for
<FromGitter>
<Blacksmoke16> primary lang being Ruby?
<FromGitter>
<alexherbo2> I'm having issues with file without extensions, like bash scripts, using shebangs.
<mfiano>
No, Lisp :)
<FromGitter>
<Blacksmoke16> (()ah i see)()()
<mfiano>
I tried Nim a couple years ago, but the compiler was very buggy for a 1.0 release, and the community was quite toxic.
<FromGitter>
<Blacksmoke16> @alexherbo2 is a method that you can specify a default for those cases
<FromGitter>
<Blacksmoke16> if that helps
<FromGitter>
<alexherbo2> how to return from a capturing block?, I'm using `next` in my block, but would like to allow `return`
<FromGitter>
<emanzx> it seem like the inotifywait does not run.. maybe exited
<FromGitter>
<emanzx> but it works ok if I used backtick
<FromGitter>
<emanzx> try to use Process.new as it will not wait for the process to finish.. I do this as sometimes.. inotifywait just freeze.. and I would force kill it with kill -9
<FromGitter>
<Blacksmoke16> might be worth trying like `"-e", "create"`, not sure if that would make a diff tho
<FromGitter>
<Blacksmoke16> versus `"-e create"`
<FromGitter>
<emanzx> oh.. so I need to split all the args?
<FromGitter>
<emanzx> ok I test first
<FromGitter>
<Blacksmoke16> maybe? could also define the output/error IOs to be the parent process which might give a clue
<FromGitter>
<emanzx> thanks @Blacksmoke16 I will add the extra for error checking
<FromGitter>
<Blacksmoke16> 👍 can also pass any `IO` for them
<FromGitter>
<Blacksmoke16> like if you wanted to capture it in an `IO::Memory` or something
<FromGitter>
<emanzx> noted. for now I just read the process output from file. I think its okay for now..
<FromGitter>
<emanzx> but I will keep in mind about the IO::Memory
<FromGitter>
<RespiteSage> What's up with 1.1.0? It looks like there's a GitHub release, but no blog post or forum thread.
elf_fortrez has quit [Quit: Client closed]
elf_fortrez has joined #crystal-lang
elf_fortrez has quit [Ping timeout: 246 seconds]
<mfiano>
I'm confused about "require" and the default directory structure of "crystal init"
<FromGitter>
<RespiteSage> What about it?
<mfiano>
The language reference says the typical project layout is to have project/src/file.cr with: require "mylib", and project/lib/mylib/mylib.cr would get loaded. Why then, is lib/ added to the git ignore file? Also why can't I just resolve my own code in the src directory?
<FromGitter>
<Blacksmoke16> `lib` directory is for dependencies
<FromGitter>
<RespiteSage> ^
<FromGitter>
<RespiteSage> Your own code should go in `src/`, just like you want to.
<FromGitter>
<Blacksmoke16> like external shards/libraires you depend on. e.g. `vendor` in PHP/bundler
<FromGitter>
<RespiteSage> When resolving your own code, you just need to use relative paths.
<mfiano>
So I must use the relative designator for require in src/file.cr, like: require "./mylib", and it should find src/mylib/mylib.cr ?
<FromGitter>
<RespiteSage> Close, but you would need `require "./mylib/mylib"` in that case.
<FromGitter>
<Blacksmoke16> i usually skip that extra directory under src
<FromGitter>
<Blacksmoke16> i dont really see the benefit of it
<FromGitter>
<RespiteSage> It's not really that different from how you do it in oq. I just tend to put a little more of the logic in the subdirectories.
<FromGitter>
<RespiteSage> Oh? Fortran?
<FromGitter>
<RespiteSage> Or something else?
<FromGitter>
<Blacksmoke16> Lisp ^
<mfiano>
Yep
<mfiano>
Lisp
<FromGitter>
<RespiteSage> Oh, I missed that.
<mfiano>
What is oq?
<FromGitter>
<Blacksmoke16> but thats how i do it, only diff is my main "entrypoint" file just lives with the rest of the files
<FromGitter>
<Blacksmoke16> are you familiar with `jq`?
<mfiano>
No
<FromGitter>
<RespiteSage> Well, no questions are stupid questions. :)
<FromGitter>
<Blacksmoke16> > A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
<mfiano>
btw which shards database/search website do you recommend. I noticed there are like 4 or 5 after the one i used has been down for some time
<mfiano>
?
<FromGitter>
<RespiteSage> You can't go wrong looking through @Blacksmoke16's projects, though maybe don't worry too much about understanding the macros yet (stuff in `{{ }}` or `{% %}`, usually).
<mfiano>
Crystal macros are very understandable, being a small subset of Lisp macros
<FromGitter>
<RespiteSage> To be honest, I'm not sure. I tend to prefer shardbox.org, but it often doesn't have stuff I'm looking for.
<FromGitter>
<RespiteSage> awesome-crystal (https://github.com/veelenga/awesome-crystal) is a good starting point for quality applications and libraries of various kinds, but it's far from comprehensive.
<mfiano>
Ok yeah I noticed shardbox tracks ~1k, and the (now down) crystalshards.xyz had ~6k
<FromGitter>
<RespiteSage> Yeah. And for whatever reason the language-constrained search on GitHub also rarely works for me.
<FromGitter>
<Blacksmoke16> shardbox is curated as is awesome-crystal, others just scrape GH
<mfiano>
the * search on github rarely works good ;)
<FromGitter>
<Blacksmoke16> only for the reason to make it more obs what the entrypoint file is?
<FromGitter>
<RespiteSage> Yeah, basically. I also like splitting out the driver and configuration logic from the rest of the application logic. Though that does make it hard to test the driver and configuration logic.
<mfiano>
to be fair, my first project was actually going to be a library, so maybe i should have clarified before asking :)
<FromGitter>
<Blacksmoke16> @RespiteSage take a look at `oq_cli.cr`
<FromGitter>
<Blacksmoke16> might be easier to test
<FromGitter>
<RespiteSage> Yeah, libraries bypass those considerations.
<FromGitter>
<Blacksmoke16> i.e. use option parser to process the args and create an instance of the actual type, passing in those args
<mfiano>
Doubtful, as all the new kids seem to prefer vscode, but anyone using vim/nvim for crystal?
<FromGitter>
<RespiteSage> I am one of those new kids, but I know I've seen people talk about using vim/nvim (and at least one or two other terminal editors) when writing Crystal.
<mfiano>
I guess one of the questions I have is editor agnostic...is crystalline the preferred LSP server?
<FromGitter>
<Blacksmoke16> does that `spec` method exist on all those types in the union?
<FromGitter>
<jwaldrip> Let me double check
<FromGitter>
<Blacksmoke16> it seems the type of that union is being collapsed into their parent `Pyrite::Kubernetes::Object+` type which doesn't have that method
<FromGitter>
<Blacksmoke16> afaik its the same as the `^` in other langs
<riza>
mfiano: the idea with ~> is that it allows for upgrades within the specified point but no higher
<FromGitter>
<Blacksmoke16> just a shortcut to say allow versions within this range
<riza>
so if you ~> x.y.z, you leave room for z to increment but not y
<FromGitter>
<Blacksmoke16> ^
<riza>
and if you ~> x.y, y can increment, z can be anythnig and x cannot change
<mfiano>
Oh very good. I don't see why you would want to leave room for y or x to upgrade...how can you know anything other than a patch won't break your code?
<riza>
its used under the assumption that the project you're referencing follow SemVer
<FromGitter>
<alex-kampa> Thanks @Blacksmoke16 your solution works, even though ⏎ ⏎ ```puts [1, 2, 3, 4, 5].reduce(0) { |acc, i| acc = acc + 1 if i.to_s =~ /3/ }``` ⏎ ⏎ but ok I guess that's the price to pay for a complied language ... and shows that the transition from Ruby to Crystal is not always easy. [https://gitter.im/crystal-lang/crystal?at=60f097b938da567d82a15aa9]
<riza>
mfiano: if the project is following SemVer, then you know that anything which is a breaking change is a major version increment
<mfiano>
Ok I see
<FromGitter>
<Blacksmoke16> @alex-kampa whats the end goal of this code?
<FromGitter>
<Blacksmoke16> i noticed i had `acc + i` instead of `acc + 1`, so are all you wanting to do is count the number of time `3` is in the array?
<FromGitter>
<alex-kampa> counting elements in an array that match a certain regex
<FromGitter>
<alex-kampa> at this stage just playing around with various ways to achieve that
<mfiano>
on save, vim-crystal seems to annotate the margin and with error icons, and when cursor is on one of those lines, message in status bar
<FromGitter>
<Blacksmoke16> ah nice, i know sublime runs the formatter on save as wel, is super nice
<mfiano>
Yeah vim-crystal seems to run the formatter (optionally [disabled by default for some reason]), and ameba if available, though no mention of that or switch for it
<mfiano>
Day 1 actually getting the tooling set up and writing a small amount of code, and I must say, Crystal was easier to get comfortable with than most of the few dozen or so languages I've tried.
<FromGitter>
<Blacksmoke16> 👍
elf_fortrez has joined #crystal-lang
<mfiano>
development_dependencies are included when not building with --release, right, or is there some other criteria that classifies what "development" means?
<FromGitter>
<Blacksmoke16> they're dependencies not used in the final build of the code
<FromGitter>
<Blacksmoke16> i.e. ameba, and testing stuff
<mfiano>
Right, I'm looking at debug.cr right now...they say you can call Debug.enabled = true if you don't want to set an env var, so I'm wondering if I can check some flag as to not call that in release builds
<FromGitter>
<Blacksmoke16> would be true whenever its built without `--release`
<mfiano>
You mean the inverse ;)
<mfiano>
But, thanks
ur5us has joined #crystal-lang
<FromGitter>
<Blacksmoke16> i mean `Debug.enabled` would be true w/o `--release`
<mfiano>
Oh yes you're right, I read your description wrong.
<mfiano>
It might be about time for bed :/
<FromGitter>
<Blacksmoke16> but to answer your earlier question doing like `shards build --release` would also technically install dev dependencies, but is likely you're not requiring those in your main code anyway.
<FromGitter>
<Blacksmoke16> would want to use `--production` or `--without-development`, can do `shards --help` for more info
<mfiano>
Where is a good place to put such meta-code as the above?
<FromGitter>
<Blacksmoke16> would need to go in your main entrypoint file, or some other file that requires it
<FromGitter>
<Blacksmoke16> oh i have an idea
<FromGitter>
<Blacksmoke16> have a `debug.cr` file that you put this stuff in
<mfiano>
Does it matter that it's before the main entry point's "require"s?
<FromGitter>
<Blacksmoke16> then you can add a `{% skip_file if flag?(:release) %}` so that the code isn't processed in release mode
<mfiano>
Oh hmm...and where would that macro form go?
<FromGitter>
<Blacksmoke16> first line of `debug.cr`
<mfiano>
I like that better. It probably means I have to explicitly require debug.cr before other requires for this to work properly, rather than an arbitrary *...or I could be wrong
<FromGitter>
<Blacksmoke16> i would advise against using like `require "./**"`
<mfiano>
Yeah I would too
<mfiano>
Though I must be doing something wrong here.
<mfiano>
Renaming the above gist to debug2.cr and it works
<mfiano>
how odd
<mfiano>
I just have to keep in mind that I shouldn't have local files with the same name as 3rd party library directories or something
<FromGitter>
<Blacksmoke16> pretty much yea
elf_fortrez has quit [Ping timeout: 246 seconds]
lucf117 has joined #crystal-lang
<mfiano>
nah that actually works fine. it seems to be a bug in that the errors in nvim's LSP are cached and not properly invalidated, even across restarts...
<FromGitter>
<jwaldrip> Why would `@type.subclasses` return an empty list?