<RX14>
@KINGSABRI an enumerator in ruby is an iterator in crystal
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> aaaah
<FromGitter>
<KINGSABRI> I see
<crystal-gh>
[crystal] RX14 opened pull request #5833: Print exception cause when inspecting with backtrace (master...feature/inspect-cause) https://git.io/vxYgo
<FromGitter>
<KINGSABRI> what!, markdown and markdown.to_html is a standard libs? !!
<FromGitter>
<KINGSABRI> in Python commandline, there is really a nice feature which is the commandline recognize the file extention, eg ⏎ ⏎ if you have these files `1.rb 1.cr 1.py` ⏎ then you type `python [tap]` it will select `1.py` [https://gitter.im/crystal-lang/crystal?at=5aac5e26e4ff28713a3fcaef]
<FromGitter>
<bew> yes, but it's a simple markdown parser
<FromGitter>
<bew> for our documentation generator
<FromGitter>
<KINGSABRI> also bash completion will be really neat, it seems I'm failing in live with Crystal :(
<FromGitter>
<KINGSABRI> yeah `optionparser` not really documented or more examples are missing
return0e has quit [Ping timeout: 260 seconds]
<FromGitter>
<straight-shoota> Markdown is really very limited
<FromGitter>
<KINGSABRI> it meant to be simple and limited, I believe
<FromGitter>
<bew> you mean markdown by itself? or our implementation?
<FromGitter>
<straight-shoota> Stdlib impl
<FromGitter>
<bew> ah yeah
<FromGitter>
<KINGSABRI> yeah
<FromGitter>
<KINGSABRI> by itself
<FromGitter>
<straight-shoota> I'd like to add a table to properly align the specifiers in API docs for Time::Format
<FromGitter>
<KINGSABRI> but it's elegant to find it in the stdlib
<FromGitter>
<KINGSABRI> but regardint to optionparser, still need more example in the documentations
<FromGitter>
<straight-shoota> Yes, but it's not worth much
<FromGitter>
<KINGSABRI> why?
<FromGitter>
<KINGSABRI> also I hope there is an easy way to add commands and sub command switches and to be well documented
<FromGitter>
<straight-shoota> Because it's limited support of markdown
<FromGitter>
<KINGSABRI> ah, I see
<FromGitter>
<straight-shoota> Option parser has actually a quite good documentation
<FromGitter>
<KINGSABRI> but regarding to optionparser, it's much less than what it should be
<FromGitter>
<straight-shoota> You can also look at examples in the samples folder of the repo
<FromGitter>
<KINGSABRI> optionparser is really fliexable and it's good to have better example
<FromGitter>
<KINGSABRI> ok I'll check that
<FromGitter>
<straight-shoota> What are you missing?
<FromGitter>
<straight-shoota> Oh and in compiler/crystal
<FromGitter>
<KINGSABRI> sub-command and subcommand switches
<FromGitter>
<straight-shoota> That's not supported by option parser itself
<FromGitter>
<straight-shoota> Take a look at the compiler
<FromGitter>
<bew> Note: gitter android app updated, it's working again!
<FromGitter>
<straight-shoota> Subcommands are just unshifted from the args array
<FromGitter>
<KINGSABRI> Rails handles that and you can't have an XSS unless you intentionally enable unsafe_html
<FromGitter>
<bew> can you open an issue about it on amber's repo?
<FromGitter>
<KINGSABRI> yes
<FromGitter>
<Blacksmoke16> does the class name matter when using require "fileName" or is it only based off of fileName
<FromGitter>
<aisrael> `require` only "includes" the file (in a sense). The file itself can declare many classes, with different names, or no classes at all.
<FromGitter>
<straight-shoota> you can name files and classes as you like
<FromGitter>
<Blacksmoke16> but what if the body contains more than just what i want to pass to the class?
<FromGitter>
<Blacksmoke16> dont i need to parse the body to be able to do ["desired_minerals"] ?
<FromGitter>
<bew> you could have another class for the outer object
<FromGitter>
<Blacksmoke16> would a struct work? still not super sure what the diff is
<FromGitter>
<Blacksmoke16> but i think that would be more performant?
<FromGitter>
<Blacksmoke16> bbiaf food
<FromGitter>
<bew> struct are more performant than classes, because classes must be allocated, while structs are directly on the stack
<FromGitter>
<bew> but you usually don't need the worry about it
<FromGitter>
<bew> you should use classes everywhere, and use structs only when you have performances problems IMO
<FromGitter>
<aisrael> ☝️ I use `structs` when I want "final" classes :D
<FromGitter>
<aisrael> Now if only we could declare `final` ivars (i.e., immutable classes/structs) :D
<FromGitter>
<bew> why do you want to have final classes?
<FromGitter>
<Blacksmoke16> gotcha, makes sense, thanks
<FromGitter>
<aisrael> @bew A habit from Java, open closed principle, all that. If it's meant to be subclassed, its `abstract`. Otherwise, it's "final". Though, mostly I use structs for internal value objects or data transfer objects (parameters), and full classes for domain objects, service objects, the like.
<FromGitter>
<bew> ok, yes structs are good for value object like you said, for immutability, just have getters
<FromGitter>
<Blacksmoke16> same error if you just try to `p hash.to_json`
<FromGitter>
<ezrast> @Blacksmoke16 Not a bug; `Time::Span` does not have a literal form
<FromGitter>
<ezrast> `00:00:00.001987000` doesn't mean anything
<FromGitter>
<Blacksmoke16> what should i declare the type as then?
<FromGitter>
<Blacksmoke16> or save the time as seconds and save that as a float?
<FromGitter>
<Blacksmoke16> yea that'd prob be best solution
<FromGitter>
<ezrast> Something like `Time::Span.new(0, 0, 0, 0.001987000)` if you want an actual `Span`.
<FromGitter>
<Blacksmoke16> use case is it gets created from like Time.now - start_time
<FromGitter>
<Blacksmoke16> so looks like i can just do like (Time.now - start_time).seconds or something along those lines
<FromGitter>
<ezrast> makes sense
<FromGitter>
<Blacksmoke16> how do you guys handle all the other classes you use for data modeling?
<FromGitter>
<Blacksmoke16> like put them at the top of the main class/module they used in or?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 263 seconds]
<FromGitter>
<aisrael> @Blacksmoke16 I usually use a `module` to "namespace" them in
<FromGitter>
<aisrael> And, when I'm lazy, I don't pay particular attention to where exactly I declare them. Sometimes they get their own file under `src/module/` sometimes they're all just under `src/`, or, sometimes they can be found buried somewhere inside `module.cr` :D
<FromGitter>
<Blacksmoke16> :p gotcha
_whitelogger has joined #crystal-lang
<FromGitter>
<ezrast> Is there a way to make `arr` be an `Array(Float64) | Array(Int32) ` instead of an `Array(Float64 | Int32)`? https://carc.in/#/r/3qpp
<FromGitter>
<bew> Yes, create the array in the ternary
<FromGitter>
<ezrast> well, yes
<FromGitter>
<ezrast> assume I already have a union type for some reason though
<FromGitter>
<bew> Or make a if to check the type of `x`, and make 1 array in if branch and else branch
<FromGitter>
<bew> Otherwise.. no, not possible
<FromGitter>
<ezrast> aye aye, thanks
<FromGitter>
<bew> Because what you're basically creating an Array with type of `x`, and at this point, `x`'s type is `Float64 | Int32`
<FromGitter>
<bararchy> Morning :)
alex`` has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
<FromGitter>
<c910335> Is it possible to write the documentation of `property`, `class_property`, etc? ⏎ I tried but only the setter part is documented.
dragonkh has joined #crystal-lang
<dragonkh>
hi - how would I turn Random::Secure.random_bytes(96 / 8) into a Array(UInt32) ?
<dragonkh>
I basically want a random array of UInt32
Groogy has quit [Disconnected by services]
<dragonkh>
oh I think Random::Secure can do it somehow
Groogy2 is now known as Groogy
<Groogy>
Morning
Groogy_ has joined #crystal-lang
<FromGitter>
<straight-shoota> @c910335 use `getter` and `setter` independently to document them
<FromGitter>
<straight-shoota> `property` is not helpful in this regard
<oprypin>
dragonkh, how big is the array that you want?
<wuehlmaus>
i just found out that with btrfs where it's not possible ot use a swapfile [silly me forgot to include swap on my 4GB Ram netbook] i can use zswap and was able to compile git crystal with that, great, i am happy :)
<FromGitter>
<c910335> I found that `property` duplicates the documentation for the two generated methods. ⏎ But `property!` only documents the setter part. ⏎ It's weird.
DTZUZO_ has joined #crystal-lang
<FromGitter>
<straight-shoota> yes, that sounds strange
<FromGitter>
<straight-shoota> it's probably a `ditto` in the `property!` macro
<FromGitter>
<straight-shoota> but still, it usually makes no sense to use the same documentation for getter and setter anyway
<FromGitter>
<straight-shoota> no I was wrong
<FromGitter>
<straight-shoota> the `property*` macros don't change any documentation
<FromGitter>
<straight-shoota> so it should not duplicate the doc comment in any case but only attach it to the first method defined
<oprypin>
straight-shoota, you underestimate the power of macros
<FromGitter>
<straight-shoota> @oprypin sure, internal APIs are usually not documented - or at least they don't need to be at the same level as API docs
<FromGitter>
<Blacksmoke16> Can i require a ruby class to use its methods in a crystal file?
<FromGitter>
<Blacksmoke16> say for a benchmark of crystal vs ruby
crystal-lang153 has joined #crystal-lang
crystal-lang153 has quit [Ping timeout: 260 seconds]
<RX14>
no
<RX14>
crystal isn't ruby
<RX14>
nothing like it really - outside of syntax
<FromGitter>
<Blacksmoke16> i figured
<FromGitter>
<Blacksmoke16> plan b!
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
<FromGitter>
<Blacksmoke16> fun fact, rewriting my LP solver into crystal made it 32x faster
return0e has joined #crystal-lang
<FromGitter>
<t0nyandre> Wow.. I will connect to the irc channel when I her onto my computer! You guys have given me so many good replies and the app haven't told me 😱
<FromGitter>
<t0nyandre> RX14, do you use spacemacs or just emacs? What's the pros and cons there?
<RX14>
spacemacs
<RX14>
and it's just because vim with more features
<FromGitter>
<t0nyandre> Can I ask to look at your . spacemacs file? :-P I just can't seem to get it the way I want it to be :-P
<FromGitter>
<t0nyandre> Fair enough :-)
<RX14>
the .spacemacs file is pretty good by default
<RX14>
what do you want to change
<RX14>
it has all the options with comments already
<RX14>
the one place where there is a proper nightly tag is on docker
<RX14>
so you'd have to run it all in docker
<RX14>
but crystallang/crystal:nightly does exist
<FromGitter>
<Sija> sounds like an option, but how about fixing travis? is that sth doable?
<RX14>
doable... with manas's help
t0nyandre has joined #crystal-lang
<FromGitter>
<Sija> should I open a ticket?
<RX14>
meh
<RX14>
well yes
<RX14>
you should
<t0nyandre>
RX14, thank you for all the help previously :) I have mixed and fixed with the spacemacs config and it wasn't that bad when I just read about those layers and got a better feeling about how they worked and what they did :)
<crystal-gh>
[crystal] Sija opened pull request #5837: Use crystallang/crystal:nightly tag for nightly releases on docker (master...circleci-docker-nightly-tag) https://git.io/vxO8s
<t0nyandre>
I see in your config u use a layer and the crystal-mode (additional package). Why is that? Again.. trying to wrap my head around this
<RX14>
t0nyandre, oh I was overriding the location of crystal-mode for testing
<RX14>
it was just so I could test crystal-mode on people's pull requests
<RX14>
since I have merge access to the crystal-mode repo
<t0nyandre>
Ah, fair enough :) I didn't add it and now I feel like this configuration of emacs is way better than what I had in vscode actually :) Quicker and I like how it feels
<t0nyandre>
One thing we need to add though is crystal-lang icons to the "all-the-icons.el" file
<t0nyandre>
my neotree feels empty without it :(
<RX14>
neotree still downs't support trees in multiple frames :(
<t0nyandre>
for me the SPC-f-f was the better alternative, but those icons were nice as eyecandy though! except not having the crystal icons :P
alex`` has quit [Quit: WeeChat 2.0.1]
<t0nyandre>
bbl.. will be on gitter but the electrician are taking my power :(