RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
<FromGitter> <j8r> Maybe. Nevertheless, the common idiom is https://play.crystal-lang.org/#/r/64ce
<FromGitter> <j8r> Yes, you can have deep nested blocks and if – but thats clearer
<FromGitter> <j8r> We can see there is a type restriction condition to execute code
<FromGitter> <j8r> Alpine 3.9 πŸŽ‰
<FromGitter> <j8r> It feels strange to have my name in the commit stats...
<FromGitter> <dscottboggs_gitlab> congrats @j8r
<FromGitter> <dscottboggs_gitlab> has anybody run into an error when parsing YAML and JSON that just says `error {stack trace} instantiating 'allocate()'`?
<FromGitter> <Blacksmoke16> Mm can't say I have
<FromGitter> <dscottboggs_gitlab> that's weird you've done a lot with serialization
<FromGitter> <Blacksmoke16> Got an example?
<FromGitter> <dscottboggs_gitlab> Only in context
<FromGitter> <dscottboggs_gitlab> I've seen it before, but never been able to create a minimal example
<FromGitter> <Blacksmoke16> Fair enough
<FromGitter> <dscottboggs_gitlab> I'll try again
<FromGitter> <dscottboggs_gitlab> oh shit I think I got it actually
<FromGitter> <dscottboggs_gitlab> damn, it's giving me a different error, but you can get the idea from here https://carc.in/#/r/64cg
<FromGitter> <dscottboggs_gitlab> oh actually that's not what I have either
<FromGitter> <dscottboggs_gitlab> and it works fine when I put it like I have it in my code https://carc.in/#/r/64cj
<FromGitter> <Blacksmoke16> Hmm
<FromGitter> <dscottboggs_gitlab> is it possible to be something that only happens when I split things up across multiple files?
<FromGitter> <dscottboggs_gitlab> here's where I am so far, https://carc.in/#/r/64co
g- has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <Blacksmoke16> Why the nested classes?
<FromGitter> <dscottboggs_gitlab> just makes it easier to reason about I gues
<FromGitter> <dscottboggs_gitlab> I suppose I could get rid of that, and include YAML::Serializable directly on the class, then add annotations everywhere..
<FromGitter> <dscottboggs_gitlab> ...but crystal's annotations are so ugly...haha
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter> <dscottboggs_gitlab> I guess FileMetadata is a really big class and I was just trying to atomize it a bit
<FromGitter> <Blacksmoke16> Wouldn't modules work better?
<FromGitter> <dscottboggs_gitlab> Sorry, I don't see how `include`ing a module with a serializer class would change anything? or do you mean with manual serialization in the module?
<FromGitter> <dscottboggs_gitlab> oh, actually, I can't include Serializable directly onto the class, because the data that's being serialized is only a partial state, it's merged in on top of existing data, and you can't create a `FileMetadata` solely from the information stored in the config file.
<FromGitter> <dscottboggs_gitlab> I guess I could use some aliases and NamedTuples since they have a`{#to,.from}_yaml`
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> just not used to seeing that nested class pattern
return0e has quit [Remote host closed the connection]
DTZUZO has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> Really? I use it a lot in crystal, just to like dry up or partition a set of related attributes. It doesn't do anything weird to the code does it? I just figured it nested a namespace under it
<FromGitter> <Blacksmoke16> yea thats normally what id use a module for, just namespacing related code
<FromGitter> <dscottboggs_gitlab> but modules are functional namespaces
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/64fc
<FromGitter> <Blacksmoke16> be a bit diff but should act similarly to what you were doing with the nested classes?
<FromGitter> <kevinelliott> @j8r dppm looks pretty cool actually
<FromGitter> <kevinelliott> I’m not a huge fan of the name itself, I don’t think it would catch on.
<FromGitter> <kevinelliott> But the concept is good. The idea of a cross-platform package manager makes me really happy.
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> anyway, im off to bed o/
<FromGitter> <kevinelliott> goodnight @Blacksmoke16
<FromGitter> <dscottboggs_gitlab> @Blacksmoke16 finally got something to compile by ditching all compile-time checks :(
<FromGitter> <kevinelliott> Just a little thing I’m working on that I wanted to show… http://www.cry.st/til
<FromGitter> <dscottboggs_gitlab> @kevinelliott nice
<FromGitter> <kevinelliott> A lot of things to do still...
DTZUZO has quit [Ping timeout: 245 seconds]
<FromGitter> <j8r> @kevinelliott the name is supposed to be short, like other package managers like apk, apt, nix, brew etc
<FromGitter> <j8r> or port
<FromGitter> <kevinelliott> @j8r I favor apt/brew for names since they sound like words too
<FromGitter> <j8r> looks the same for me, apt/yum/dnf are a sequence of 3 letters - ok here the project is 4 :)
<FromGitter> <j8r> anyway the goal is to build in top of this tool, which will provide an API, a web UI
<FromGitter> <kevinelliott> what word is dnf?
<FromGitter> <j8r> Which will have a nice name :)
<FromGitter> <kevinelliott> yum == tasty, apt == appropriate, brew == make beer/coffee/tea
<FromGitter> <j8r> Dandified Packaging Tool
<FromGitter> <kevinelliott> anyway, just a suggestion, since it will help people remember and verbalize
<FromGitter> <kevinelliott> call it dandy then :)
<FromGitter> <j8r> and apk, lol :)
<FromGitter> <kevinelliott> apk sucks
<FromGitter> <j8r> Ok I'll think about it
<FromGitter> <kevinelliott> :)
<FromGitter> <j8r> anyway it's supposed to be a geek - moderatly low level tool
<FromGitter> <j8r> A noob-friendly web ui is planned to be built on top, or other non-cli GUIs
<FromGitter> <kevinelliott> they are all geek tools :)
<FromGitter> <kevinelliott> geeks are still human, right?
<FromGitter> <kevinelliott> (some anyway ;) )
<FromGitter> <j8r> haha right - I hope
<FromGitter> <j8r> @kevinelliott have you ideas?
<mps> j8r: did you notice crystal in release notes for Alpine 3.9
<FromGitter> <j8r> yes mps - great
<FromGitter> <j8r> you have done 20 commits :o
<FromGitter> <j8r> gj
<mps> we were not sure if it is important and I was tempted to ask here last night, but decided it is important for crystal community
<FromGitter> <kevinelliott> @j8r jam β€” just a (package) manager
<mps> it was guessing, but i feel it I'm right?
<FromGitter> <j8r> don't know - personally I think it's good
<FromGitter> <j8r> this infos could depend on the popularity, downloads stats
<FromGitter> <j8r> if crystal isn't much installed, it would probably not worth it to mention it. But if it does, it worth it
<mps> in may/june 2018, release 3.8, crystal is 0.26
<mps> Alpine doesn't track installations or download of packages
<FromGitter> <j8r> too bad
<mps> j8r: why? a loot of people don't like to tracked
<FromGitter> <j8r> I an not talking about tracking people
<mps> oh, sorry
<FromGitter> <j8r> on server side you can count the download requests
<FromGitter> <j8r> IIRC Debian does
<FromGitter> <j8r> it's not hard to do, and will provide a simple metric to know where prioritize the work
<mps> download count could give wrong 'impression'
<FromGitter> <j8r> just suggesting :)
<FromGitter> <j8r> its better than nothing, I guess
<FromGitter> <j8r> @kevinelliott I don't like the meaning of the word :/
<FromGitter> <kevinelliott> @j8r plum β€” packages love ur mom :P
<mps> not sure, Alpine is known for a loot 'del/add' i.e. delete and install fast
<FromGitter> <kevinelliott> @j8r rum β€” really useful (package) manager
<FromGitter> <kevinelliott> @j8r gum β€” general unit manager β€” unit == package, gum == chew it up
<FromGitter> <vladfaust> Excuse me, are you talking about potential Crystal shard manager tool naming?
<FromGitter> <kevinelliott> @vladfaust no, we are talking about @j8r’s package management tool
<FromGitter> <vladfaust> Like, Unix package manager?
<FromGitter> <kevinelliott> Multi-platform package manager
<FromGitter> <vladfaust> Oh, alright
<FromGitter> <vladfaust> I just wanted to share an idea of Crystal shard manager -- shaman. That's simple, but allows to stick to a legend and nice shamanise design with Voodoo and stuff :)
<FromGitter> <kevinelliott> @vladfaust beyond what `shards` already does?
<FromGitter> <vladfaust> I'm talking about central repository, ofc
<FromGitter> <kevinelliott> @vladfaust I am working with @straight-shoota on a platform similar to RubyToolbox
<FromGitter> <vladfaust> More or less, yes
eisque has joined #crystal-lang
<FromGitter> <vladfaust> Shardbox, btw. I have this username on github, can give it to you
<eisque> How do you extend a module from library and add additional macros to it?
<FromGitter> <vladfaust> @eisque ⏎ ⏎ ```module SomeNamespace::TheModuleIWantToExtend ⏎ macro foo ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c51689bceb5a2264f64a389]
<FromGitter> <kevinelliott> @vladfaust Cool, thanks for the offer. I can discuss with @straight-shoota … we are considering *toolbox/*box naming, but want to chat with the RubyToolbox guys first and get their blessing if we do go that route. FWIW, `shardbox` is definitely different enough that I don’t think it would impose to seriously on their name
<FromGitter> <vladfaust> It's absolutely different :)
<FromGitter> <vladfaust> Shardbox is like jewelry box, and toolbox is with hammers and wrenches
<FromGitter> <eisque> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c516ad19221b9382de5fa79]
<FromGitter> <vladfaust> Yeah, I like this, looks sexy
<FromGitter> <eisque> um, that doesn't work tho
<FromGitter> <bew> you need to use `puts {{content}}`
<FromGitter> <eisque> ok let me clarify again (I am really not getting it). I want to extend https://github.com/z64/discordcr-plugin and have some additional stuff available on the plugin module so when I include it like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c516eb0f46373406a236a4e]
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
eisque has quit [Ping timeout: 256 seconds]
<FromGitter> <hanneskaeufler> Does anyone have good examples for the `pretty_print` module? Trying to achieve printing a block of text to the console that is at most 80 chars wide and wraps at spaces between words. Somehow I struggle with this.
ternarysolo has joined #crystal-lang
<FromGitter> <mavu> take 80 chars, go backwards to first space you find, remove from beginning to that point and print it, repeat with the rest?
<jokke> any lucky devs around? is it currently possible to have array columns?
<FromGitter> <mavu> Quick question: If I start a fiber with spawn do, and fork after that, that fiber gets forked too, and I have 2 running, right?
<FromGitter> <hanneskaeufler> @FromIRC jokke, no, that's not a supported column type out of the box right now.
<FromGitter> <hanneskaeufler> @mavu Sure that'd work, I was hoping to do something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c51a56313a2814df6efb1c2]
<FromGitter> <bew> @mavu 2 fibers + the ones already running (the current one, and another one created by the stdlib at beginning of your program iirc)
<jokke> alright
<FromGitter> <mavu> @bew ok, thanks
moei has joined #crystal-lang
<FromGitter> <mavu> @hanneskaeufler I jsut tried, and I can't get it to work either.
<jokke> @hanneskaeufler: where should i put more complex application logic in lucky? something like service objects
<FromGitter> <mavu> Pretty prints obj into io with the given width as a limit and starting with the given indentation. ⏎ https://play.crystal-lang.org/#/r/64lq
<FromGitter> <mavu> Does not seem to work as advertized :P
<FromGitter> <hanneskaeufler> exactly, thought I was just not understanding correctly
<FromGitter> <hanneskaeufler> will probably file a bug ... :D
<z64> i don't think PrettyPrint is intended to wrap strings like that
<FromGitter> <mavu> @z64 well, then the documentation could use a clarification, but one of the 2 is definitely off.
<jokke> hm i think a form will do fine for my logic
<jokke> a virtual form that is
<jokke> another question: are forms run in transactions?
<jokke> specific case: i have a create action that allows me to submit nested data. for me to make the associations i'd need the created record.
<jokke> if something goes wrong with creating the associated records the whole thing should roll back
<z64> @mavu if you see the pretty printer specs, like here for example https://github.com/crystal-lang/crystal/blob/master/spec/std/pretty_print_spec.cr#L248-L264, the printer is designed to wrap "breakable" elements. it is an elements job to describe to the printer how it can be broken up by implementing `def pretty_print(pp)`, and if you see Strings implementation, the only "breakable" element is a newline
<FromGitter> <hanneskaeufler> Btw there is a "Lucky" chat room as well, you might get more specific answers there jokke: https://gitter.im/luckyframework/Lobby
<jokke> oh, right
<jokke> sorry
<z64> PrettyPrinter docs references the ruby implementation, which has a disclaimer that "actual outputs may overflow maxwidth if long *non-breakable* texts are provided"
<FromGitter> <girng> good morning
<FromGitter> <theretromaniac> Good afternoon
jemc has joined #crystal-lang
DTZUZO has joined #crystal-lang
moei has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> o/
Jenz has joined #crystal-lang
<Jenz> Nice, crystal .27 is listed as a significant update in Alpine Linux 3.9 release, together with Linux, GCC and similar
<FromGitter> <j8r> mps do you know why contributors are sorted alphabetically, vs. in commits number?
<Jenz> One commit *can* be much more than a dozen
<Jenz> I.e. the number of commits don't neccesarily say much about how much work has been done in them. I guess they can be misleading
<FromGitter> <j8r> sure, it certainly means more than the name of the guy
<FromGitter> <j8r> usually top committers are more involved in the project - not always
<mps> j8r: first version was by number of commit and looked as some kind of ranking, most commits at the top and least at bottom
<mps> but changed to alphabetical order in 'last minute' because it doesn't reflect real contribution
<mps> it is hard, if actually is possible, to measure contribution on such project
<mps> Jenz is right
<mps> for example, one can make some number of cosmetical changes and every change in separate commit so count of his commits grows by large
<mps> and someone can make a big job in important subsystem with just one commit, so you understand why the list in alpha order
<mps> Jenz: I thought that crystal upgrade to 0.27 is important for crystal community so we added it. Thought to ask here last night should we add it in list, when the release notes outlined but didn't had enough time
<FromGitter> <j8r> this isn't about ranking
<FromGitter> <j8r> it's about sorting
<Jenz> mps: Hehe, it's awesome. Love how Crystal is slowly but surely gaining the reputation it deserves
<mps> j8r: first version looked as some kind of ranking
<FromGitter> <j8r> so why specifying commits numbers then?
<FromGitter> <j8r> or, being able to sort ourself by name or by commit in client side - two columns
<mps> I also have split mind about it, not sure if these numbers should be there but they doesn't hurt at the end
<mps> looks little strange, but I don't care
<FromGitter> <j8r> then having the ++additions and --deletion? Don't know, I think they will better be in a separated "stats" page
<mps> there is a link to git log (https://git.alpinelinux.org/aports/log/?h=v3.9.0)
<jemc> excited about the alpine release - I was actually just wishing for that when I was working this weekend on a Dockerfile where I had to use alpine edge temporarily: https://github.com/jemc/mare/blob/ca22ca2ce62c3efefd6dc3222951eb5d1ecc9f71/Dockerfile#L1
<jemc> thanks for your work to maintain it, mps!
<FromGitter> <j8r> I always use alpine@latest with alpne@edge repo added only for crystl and shards
<FromGitter> <j8r> jemc crystal 0.27.1 will be out soon
<mps> jemc: you are welcome
<jemc> j8r: I don't necessarily care about having the latest and greatest in every case, and would prefer to have reproducible. The only reason I had to use edge here was because I found a lot of typechecking broke for me in this project when I downgraded to whatever older version was on alpine 3.8
<mps> j8r: well, I had a hope that the 0.27.1 will be released last month to add it, but it is not.
<FromGitter> <j8r> alpine stable and crystal stable will never be synced - that's normal
<FromGitter> <j8r> why using crystal@edge won't be reproducible jemc?
<jemc> I'm not informed enough to say for sure - maybe it is. I just took the approach of assuming that I should increment versions manually
<jemc> particularly, I want to make sure that I notice if a different version of LLVM is used to build crystal, because I have to use the same LLVM version to build pony in that image for things to play nicely together
<FromGitter> <j8r> i see
Jenz has quit [Quit: leaving]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/64o9 @j8r passing the obj around was perfect
<FromGitter> <codenoid> how are you
<FromGitter> <j8r> @Blacksmoke16 πŸ‘Œ passing a class Builder is what's done with String , JSON and YAML too
<FromGitter> <Blacksmoke16> yea just never put 2 and 2 together
<jokke> hey there
<FromGitter> <Blacksmoke16> o/
<jokke> what's the limit on the length of the query part of a request in crystals http server?
<FromGitter> <j8r> @Blacksmoke16 I mean Parser, sorry
<FromGitter> <j8r> for string it's an IO that's passed
<FromGitter> <j8r> the pull_parser is passed to keep track of the consumed string
<FromGitter> <j8r> or io
<FromGitter> <Blacksmoke16> sadly had to go back to the .map vs using the blocked `join` method
Dreamer3 has joined #crystal-lang
<FromGitter> <girng> how to get time since app started again?
<FromGitter> <r00ster91> There's `Time.monotonic`: https://crystal-lang.org/api/0.27.0/Time.html#monotonic:Time::Span-class-method ⏎ but it's not from the app start, I believe it starts when you boot up your PC.
<FromGitter> <j8r> just initialize a constant
<FromGitter> <j8r> `START_TIME = Time.now`
<FromGitter> <j8r> or, more complicated, https://crystal-community.github.io/hardware/Hardware/PID/Stat.html#starttime%3AInt32-instance-method
<FromGitter> <r00ster91> oooh yes, sorry. Doing that with a fiber is an awful idea. Of course with something like this and then when you want to get the time, divide the constant by the current time
<FromGitter> <j8r> you can do like UNIX_EPOCH
<FromGitter> <j8r> time subtraction
<FromGitter> <girng> thank you got it
laaron has joined #crystal-lang
<FromGitter> <girng> πŸš€ πŸ“
laaron- has quit [Ping timeout: 256 seconds]
<FromGitter> <Prutheus> Can I write a struct serialized to bytes into a file like in C?
<oprypin> Prutheus, yes. are you sure you want that though? is this for interoperability with an existing format?
<oprypin> i also wouldn't call this "serialized" lol
<oprypin> anyhow, it's the good ol' `f.write(obj.to_unsafe.to_slice(sizeof(typeof(obj))))`
simerax has joined #crystal-lang
<oprypin> or how about `f.write(pointerof(obj).to_slice(sizeof(typeof(obj))))` for structs
<oprypin> and im pretty sure there's a mistake in those, probably needs more `.as(Void*)`
early has quit [Ping timeout: 244 seconds]
early has joined #crystal-lang
<z64> the ideal way to do this is to implement `T.from_io(io, format)` and `T#to_io(io, format)`, and use `io.write_bytes(t, fomat)`
ternarysolo has quit [Ping timeout: 244 seconds]
moei has joined #crystal-lang
<FromGitter> <Blacksmoke16> prob an issue with the automatic casting
<FromGitter> <girng> https://play.crystal-lang.org/#/r/64rd hmm it's an Int32
<FromGitter> <girng> hash converts the Int32 to a Int64 if it matches it type?
<FromGitter> <girng> internally*, if it's a literal
<FromGitter> <Blacksmoke16> is what allows the int32 in the working example to be auto casted to int64
<FromGitter> <Blacksmoke16> at least this is my guess
<FromGitter> <girng> i did `hash[x.to_i64]` and it works i was just curious why i need to convert this to Int64 if it already did it before lol
<FromGitter> <Blacksmoke16> `When putting intermediary expressions, or intermediary assignments, it stops working.`
<FromGitter> <girng> but i assume cause the x is in a block it's set to Int32
<FromGitter> <Blacksmoke16> might be related?
<FromGitter> <girng> prob thanks i was just curious. i learn new stuff all the time
simerax has quit [Remote host closed the connection]
cyberarm has quit [Ping timeout: 244 seconds]
cyberarm has joined #crystal-lang