ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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
return0e has quit [Remote host closed the connection]
<FromGitter> <sam0x17> is there some trick I could use to "dump" the current heap and stack state, and "load" that state on a subsequent execution of the program? (looking for a way to hack better repl-like functionality into the language). .NET languages have a per-object way of doing this for example. Maybe some ugly low-level call to the GC plus some ugly thing that gets/sets the stack?
<FromGitter> <tenebrousedge> now that's an interesting idea
<FromGitter> <sam0x17> for my purposes, I think it would actually be most useful on a per-object basis
<FromGitter> <sam0x17> but it gets tricky when objects have references to objects
<FromGitter> <sam0x17> in the mean time, I've been literally using database migrations where I used to use my production rails repl on a real in production service xD
<FromGitter> <tenebrousedge> I reaaaaally miss not having `pry` in Crystal
<FromGitter> <sam0x17> right, and I don't care if it's slow as molasses -- I expect that
<FromGitter> <sam0x17> rust managed to get a real repl working (some googler did it)
<FromGitter> <tenebrousedge> you have `icr` right?
<FromGitter> <sam0x17> yeah icr is dangerous af
<FromGitter> <sam0x17> re-runs everything up to that point
<FromGitter> <sam0x17> imagine that in a database / web service context
<FromGitter> <sam0x17> xD
<FromGitter> <tenebrousedge> it's useful for "does this stdlib method work the way I think it does?"
<FromGitter> <sam0x17> totally
<FromGitter> <sam0x17> but I have crystal eval (or whatever it is) for that
<FromGitter> <Blacksmoke16> whats the use case for having a repl in a prod env? something like the rails console
<FromGitter> <sam0x17> exactly that
<FromGitter> <Blacksmoke16> for doing one off command and stuff?
<FromGitter> <sam0x17> yup
<FromGitter> <tenebrousedge> I've had to do debugging that way too, when I couldn't reproduce something any other way
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <sam0x17> there are workable solutions right now, but I want to make it nicer
<FromGitter> <sam0x17> something like loop over all locals in the current scope, serialize them, and then in a prelude on the next repl input prepopulate those locals using deserialization
<FromGitter> <sam0x17> but in crystal when we talk about serialization it's usually sexy serialization / JSON stuff, not a memory dump, which is what it is in .NET
<FromGitter> <sam0x17> might be able to do it by monkey-patching the GC when the repl is loaded
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <sam0x17> I suppose I could do it from the ground up and just write a dump/undump routine for all the primitive types, and then have an automatic implementation for all complex types
<FromGitter> <sam0x17> what will get tricky is when the language yells at me for not following whatever arbitrary initialization procedure some class uses
<FromGitter> <sam0x17> for structs it would work 100%
<FromGitter> <sam0x17> I think I just realized why it was easy in rust -- everything is a struct
<FromGitter> <sam0x17> aha, I can use Pointer.new to basically get a memory dump of an object
<FromGitter> <sam0x17> yeah, gonna try this
<FromGitter> <sam0x17> e.g.: ⏎ ⏎ ```array = [1, 2, 3] ⏎ ptr = Pointer(Void).new(array.object_id)``` [https://gitter.im/crystal-lang/crystal?at=5da277e24afd703a4ecd3c30]
dwdv_ has quit [Ping timeout: 268 seconds]
<FromGitter> <sam0x17> how do I specify `T` when calling a generic method with the `forall T` syntax?
<FromGitter> <tenebrousedge> example?
<FromGitter> <sam0x17> want to make this generic instead of specific to Foo: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da2853ff1c89c0758dbd3b3]
<FromGitter> <sam0x17> also no idea what happened with syntax highlighting there xD
<FromGitter> <tenebrousedge> you need a class
<FromGitter> <sam0x17> figured
<FromGitter> <sam0x17> I'll just wrap it
<FromGitter> <tenebrousedge> or a module
<FromGitter> <sam0x17> yeah gonna do `module Dumper(T)`
<FromGitter> <sam0x17> xD
<FromGitter> <sam0x17> annnnnnnnnd seg fault xDDD ⏎ https://play.crystal-lang.org/#/r/7sky
<FromGitter> <sam0x17> so apparently just dumping object memory and loading it into a new object causes some issues
<FromGitter> <sam0x17> or I did something wrong
<FromGitter> <tenebrousedge> hell if I know :/
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> your array of bytes is nil
<FromGitter> <sam0x17> literally just found that the second you messaged that
<FromGitter> <sam0x17> `Slice[nil, nil, nil, nil, nil, nil, nil, nil]`
<FromGitter> <Blacksmoke16> ye
return0e has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
<FromGitter> <sam0x17> when I use `Bytes` and `Pointer(UInt8)` I get `Bytes[164, 0, 0, 0, 32, 0, 0, 0]`, which is closer, but then segfaults in the same place. I bet the `String` is crashing it since that's a reference
<FromGitter> <sam0x17> yup, when I use some primitive instead of a String as the second field, everything works fine
<FromGitter> <sam0x17> so now I have to have it recursively deal with references I suppose
<FromGitter> <sam0x17> a start though, to be sure!!!
<FromGitter> <sam0x17> actually, it isn't working with Int64 -- they come back zero
_whitelogger has joined #crystal-lang
<FromGitter> <sam0x17> correction: only the first field will work, rest will get `1` as their value if they are an Int32
<FromGitter> <sam0x17> ahhh, `sizeof` != `instance_sizeof`
<FromGitter> <sam0x17> I need to learn more about crystal memory layout
<FromGitter> <tenebrousedge> did you read this (https://crystal-lang.org/2015/03/04/internals.html)? It's a bit dated but interesting
<FromGitter> <sam0x17> switching to instance_sizeof fully fixed my issue, yay
<FromGitter> <sam0x17> @tenebrousedge reading, thx!
Raimondi has joined #crystal-lang
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #crystal-lang
return0e has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
_whitelogger has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
absolutejam4 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 265 seconds]
rohitpaulk has quit [Remote host closed the connection]
absolutejam4 has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 240 seconds]
dwdv_ has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<FromGitter> <absolutejam_twitter> That's one of the things I love about elixir/the BEAM
<FromGitter> <absolutejam_twitter> You can jump onto a repl of a running application and inspect all of the processes and state
MasterdonX has quit [Read error: Connection reset by peer]
MasterdonX has joined #crystal-lang
gangstacat has quit [Ping timeout: 246 seconds]
gangstacat has joined #crystal-lang
HumanGeek has quit [Ping timeout: 268 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
gangstacat has quit [Ping timeout: 276 seconds]
gangstacat has joined #crystal-lang
alexherbo2 has joined #crystal-lang
gangstacat has quit [Ping timeout: 246 seconds]
gangstacat has joined #crystal-lang
gangstacat has quit [Ping timeout: 252 seconds]
dom96 has quit [Ping timeout: 240 seconds]
dom96 has joined #crystal-lang
hypercore has joined #crystal-lang
<hypercore> anyone running crystal or lucky on heroku?
<FromGitter> <absolutejam_twitter> Isn't heroku hella expensive for what you get?
<FromGitter> <tenebrousedge> they have a free tier
<FromGitter> <tenebrousedge> they're relatively expensive, but it's easier to administrate, particularly on the small scale
<FromGitter> <tenebrousedge> if I'm launching a service and want to scale quickly, heroku would likely be easier than k8s + traefik + whatever other infrastructure
<erdnaxeli> <hypercore "anyone running crystal or lucky "> What is lucky? It's not the first time I heard about it here
<FromGitter> <tenebrousedge> it's a web framework written in crystal (https://luckyframework.org/)
<hypercore> yeah heroku seems pretty bad value, i think i would only use it if i had a lot of disposable income
<hypercore> i'm using the lucky buildpack, but i'm getting this error (https://paste.ubuntu.com/p/fvzrqMQ7D4/) when i try to install it
<hypercore> any idea what's causing this? doesn't happen when i run lucky locally
<hypercore> there's no mix-manifest.json?
<hypercore> in the .gitginore that lucky provides there's a line with "/public/mix-manifest.json", i've removed in and seeing if that works
<Yxhuvud> absolutejam_twitter: no, while Heroku is kinda expensive, it the infrastructure you get for your money is good and it is *very* easy to work with.
<hypercore> it depends how much you value the convenience, but in terms of an apples-to-apples comparison of price-to-performance, a VPS is far better value
<hypercore> heroku will cost you potentially a 10x multiple of what you would pay using a VPS, if not more
<FromGitter> <tenebrousedge> that depends on how complex your app is. If you're running a half-dozen different services on an equal number of VPSs, then Heroku is likely to be cheaper initially
<Yxhuvud> Oh, sure. There are definitely companies for who the cost of doing ops is cheaper than letting heroku handle all that. And at some point you end up offloading some stuff to cheaper services.
<FromGitter> <tenebrousedge> and at any level of complexity, as you scale Heroku becomes a much worse bargain. But there are worse problems to have
<hypercore> can crystal/lucky run well on a $7 heroku instance?
<FromGitter> <tenebrousedge> better than Ruby I'm sure
<hypercore> lol that's not a very high bar though
<hypercore> i'm trying to use the heroku crystal buildpack, but now i get this error -> https://paste.ubuntu.com/p/zjFbq45bYf/
<hypercore> remote: execution of 'lucky db.migrate' failed! /bin/bash: lucky: command not found
<FromGitter> <tenebrousedge> I would guess `lucky` wasn't on the path
<FromGitter> <tenebrousedge> is there a `bin/lucky` or something?
<hypercore> in the buildpack or in my lucky project source?
<FromGitter> <tenebrousedge> the latter
<hypercore> there's no bin/lucky, only these commands -> https://paste.ubuntu.com/p/QKvYKRyMXh/
<FromGitter> <tenebrousedge> the crystal buildpack is expecting your app to be called `app`
<hypercore> oh, as in the directory that contains the app files on my localhost needs to be called `app`?
<FromGitter> <tenebrousedge> I don't think so
<FromGitter> <tenebrousedge> it should be adding `lucky` to the path
<FromGitter> <tenebrousedge> that's really weird
<FromGitter> <tenebrousedge> have you tried `heroku local` ?
<hypercore> i'm actually using dokku for this
<hypercore> although i haven't set the LUCKY_ENV env variable (https://luckyframework.org/guides/deploying/heroku), do i need to do this?
<FromGitter> <tenebrousedge> the buildpack should
<hypercore> ah ok
<hypercore> i think the command comes from the Procfile that lucky generates, on the line "release: lucky db.migrate"
<FromGitter> <tenebrousedge> maybe that should be `web: lucky db.migrate` ?
<FromGitter> <tenebrousedge> just guessing
<hypercore> the be clear the whole Procile is this -> https://paste.ubuntu.com/p/5d2KqrGWYc/
<hypercore> so "web: ./app" as the first line
<FromGitter> <tenebrousedge> 👀
<FromGitter> <tenebrousedge> yo no se
<hypercore> lol not sure what that means
<hypercore> am i missing something obvious?
<hypercore> oh "i don't know"
<FromGitter> <tenebrousedge> probably there are more informed persons here than me
<hypercore> ok, well thanks anyway for the help, i'm still pretty new to crystal so i could be missing something quite obvious
<FromGitter> <sam0x17> anyone know how I can do a `sizeof` in a macro? I'm trying to instantiate a `StaticArray` to be the size of a type that I know at compile-time (I have the `TypeNode`)
<FromGitter> <Blacksmoke16> couldnt you just do `sizeof({{@type}})`
<FromGitter> <sam0x17> StaticArray wants a CONST
<FromGitter> <sam0x17> not an Int32
<FromGitter> <sam0x17> for the size
<FromGitter> <sam0x17> and apparently sizeof is not CONST
<FromGitter> <Blacksmoke16> then just do like `StaticArray({{@type}}, 3)`?
<FromGitter> <sam0x17> I need to do something like `StaticArray(UInt8, sizeof(@type))`
<FromGitter> <sam0x17> but that isn't CONST
<FromGitter> <Blacksmoke16> got a playground link?
<FromGitter> <sam0x17> I can set one up sec
<FromGitter> <sam0x17> I'm gonna do a contrived simplification
<FromGitter> <sam0x17> oh and basically all I'm trying to do is get the raw bytes for any primitive
<FromGitter> <sam0x17> so anything that is `Value`
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/syntax_and_semantics/pointerof.html would that be useful?
<FromGitter> <sam0x17> actually here is the full example https://play.crystal-lang.org/#/r/7soo
<FromGitter> <sam0x17> `pointerof` I've been trying -- works great for classes, not for Ints and stuff
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7sop like so?
<FromGitter> <sam0x17> I could actually put the static type inside a Tuple and get the data that way but I'd rather not
<FromGitter> <sam0x17> witchcraft!!!
<FromGitter> <sam0x17> thanks!
<FromGitter> <sam0x17> I have zero understanding why that works but what I did didn't lol
<FromGitter> <Blacksmoke16> er might want to make it `\{{@type}}` so it represents the type it was included in
<FromGitter> <sam0x17> that would make sense
<FromGitter> <sam0x17> tho it seems to be doing something anyway xD
<FromGitter> <sam0x17> is there documentation anywhere for all the different like `{{}}` and `\{{}}` and `{% %}` thingys?
<FromGitter> <sam0x17> I've just sort of picked up that `\{{}}` is what you need when stuff is is created in a later hook
<hypercore> would you guys know why i get "remote: execution of 'lucky db.migrate' failed! /bin/bash: lucky: command not found" when using the heroku-crystal-buildpack to run lucky?
<FromGitter> <Blacksmoke16> the way i look at it is the first is when you want to "insert" a value into the code like `{{@type}}`, adding the `\` escapes the expression so that it doesn't execute immediately, i.e. waits until after the included hook runs
<FromGitter> <sam0x17> the lucky executable isn't in your PATH on that buildpack @hypercore
<FromGitter> <Blacksmoke16> `{% %}` is what i use for control logic like if/for etc
<hypercore> ah ok, do i have to add it manually or something? i thought buildpacks took care of this sort of thing for you
<FromGitter> <sam0x17> you will probably have to modify the buildpack to ensure that the lucky executable is in PATH -- you might have to have the lucky executable be a second build target and then ensure that your app's bin directory is in PATH, or something
<FromGitter> <sam0x17> this is probably one of those things where whoever maintains it didn't make sure the db migrate part is working
<FromGitter> <sam0x17> so in theory yes, in practice no
<FromGitter> <sam0x17> you should fork and submit a PR if there is a repo for it
<FromGitter> <sam0x17> I had to do the same a few years ago for the amber build pack
<FromGitter> <sam0x17> literally same issue
alexherbo26 has joined #crystal-lang
<FromGitter> <sam0x17> thanks, @Blacksmoke16
<FromGitter> <Blacksmoke16> if you have a lot of macro code within a hook you can also do like
<FromGitter> <sam0x17> I've gathered that as well, just wish it was documented
<FromGitter> <sam0x17> and I wouldn't feel knowledgable enough to document myself
<FromGitter> <Blacksmoke16> `{% verbatim do %}` is the same thing as adding `\` to each expression
alexherbo2 has quit [Ping timeout: 245 seconds]
<FromGitter> <sam0x17> guess you didn't like my https://github.com/sam0x17/assert.cr :P lol
<hypercore> ok thanks sam, i'll see what i can do
<FromGitter> <sam0x17> np
<hypercore> this is the buildpack btw (https://github.com/luckyframework/heroku-buildpack-crystal/blob/master/bin/compile#L97), on line 97 it exports .heroku/lucky, is that the lucky executable?
<FromGitter> <Blacksmoke16> :p didnt know it was a thing
<FromGitter> <sam0x17> lolz
<FromGitter> <sam0x17> its quite old
<FromGitter> <sam0x17> @hypercore at a glance, it looks like it yeah, but then that begs the question why it isn't finding lucky already
<FromGitter> <sam0x17> you might want to add a build step that just prints out `which lucky`
<FromGitter> <sam0x17> and see if its actually finding it (I bet it isnt)
<FromGitter> <sam0x17> and then when that doesn't work, try a build step that prints out `find -r / lucky`
<FromGitter> <sam0x17> to see if it even is anywhere in what is getting deployed
<FromGitter> <sam0x17> if a path comes back you then have the option of just calling it a day and using whatever that path is, or investigating further to have it properly included in PATH
<FromGitter> <sam0x17> also, you might have some luck using apex's `up` instead of heroku
<FromGitter> <sam0x17> I'm hosting all my crystal stuff using that now (puts it in lambdas!!!)
<FromGitter> <sam0x17> their default crystal example breaks but its easy to fix and set up how you want -- I use kemal + a bunch of custom middleware generally
<hypercore> oh cool, didn't know about apex
<FromGitter> <sam0x17> unless you're google you'll probably be in free tier as well for lambda
<FromGitter> <sam0x17> I was like mind = blown when I realized I could run a full web app in a lambda
<FromGitter> <sam0x17> I can give you my up.json file that I use if you get stuck --- I had to do a bunch of workarounds because static compilation is annoying
<hypercore> that'd be great, thanks
<hypercore> and does that work exactly? i thought lambdas are simple little functions, i didn't realize you can use lambdas with a web framework
<hypercore> *how does that work
<FromGitter> <sam0x17> they are full vm's
<FromGitter> <sam0x17> with a tiny environment
<FromGitter> <sam0x17> by default they run usually a fork of nodejs / express
<FromGitter> <sam0x17> but you can call unix executables
<FromGitter> <sam0x17> so if you bundle things properly, you can call your crystal executable
<FromGitter> <sam0x17> which is what up does (and my gcf.cr tool for google cloud functions -- dont use very old)
<FromGitter> <sam0x17> so basically if you statically compile your crystal app, you can just directly run from the javascript
<FromGitter> <sam0x17> if your dependencies are simple, you will have an easy time
<FromGitter> <sam0x17> otherwise you will want to use a really good static compilation docker image, and make your build script something like: `docker run --rm -v $(pwd):/src -w /src durosoft/crystal-alpine:0.31.1 shards build`
<FromGitter> <sam0x17> actually, edit: `docker run --rm -v $(pwd):/src -w /src durosoft/crystal-alpine:0.31.1 shards build && mv bin/[my-app] ./server`
ht__ has joined #crystal-lang
<FromGitter> <sam0x17> (it expects the final executable to be located at `./server`)
<FromGitter> <sam0x17> that's really all up does -- you run deploy and it expects an executable at `./server`
<FromGitter> <sam0x17> also handles provisioning, domains, api gateway, etc, for you
<hypercore> that's pretty handy
<hypercore> is it expensive compared to a VPS?
<FromGitter> <sam0x17> I've never had it cost an entire cent
<FromGitter> <sam0x17> let me put it that way
<FromGitter> <sam0x17> in production at my company yeah its a few dollars a month
<FromGitter> <sam0x17> for personal stuff it will always be free unless you go viral
<FromGitter> <sam0x17> lambda executions are something like 0.000001 cents per invocation
<FromGitter> <ilanpillemer> I assume this is not idiomatic..
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da367e5894dee56e5388492]
<FromGitter> <sam0x17> plus vm time for the runtime
gangstacat has joined #crystal-lang
<FromGitter> <Blacksmoke16> whats the input?
<FromGitter> <ilanpillemer> stdin
<FromGitter> <sam0x17> couldn't you just read the whole line and split on ","?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/IO.html#each_line(*args,**options,&block:String-%3E):Nil-instance-method
<FromGitter> <sam0x17> or is that not what this is supposed to do
<FromGitter> <ilanpillemer> I want to stream
<FromGitter> <ilanpillemer> as the file could get big
<FromGitter> <sam0x17> ah
<FromGitter> <ilanpillemer> so it comes in via stdin and I just process it
<FromGitter> <SewerynKaminski> f
<FromGitter> <SewerynKaminski> ff
<FromGitter> <ilanpillemer> is there an idiomatic way to steam on stdin/file?
<FromGitter> <ilanpillemer> or any IO for that matter
<FromGitter> <SewerynKaminski> Is there a simpler way to populate the array? ⏎ https://play.crystal-lang.org/#/r/7sp0
<FromGitter> <Blacksmoke16> simpler how?
<FromGitter> <sam0x17> @ilanpillemer you'll want to do `each_char` and have logic that looks for the `","` then, I guess?
<FromGitter> <SewerynKaminski> @Blacksmoke16 withot A.new(...)
<FromGitter> <sam0x17> and wrap that within an `each_line` if you also care about lines
<FromGitter> <Blacksmoke16> im going to go with no? thats how you would have to do it
<FromGitter> <Blacksmoke16> whats the use case?
<FromGitter> <SewerynKaminski> maybe [1, 2, 3] of A ?
<FromGitter> <tenebrousedge> @SewerynKaminski you could do `[1,2].map(&-A.new(Int32))`
<FromGitter> <sam0x17> ^
<FromGitter> <Blacksmoke16> missing a `>`
<FromGitter> <Blacksmoke16> but i wouldnt call the simpler :p
<FromGitter> <ilanpillemer> ok. there I declare myself idiomatic.
<FromGitter> <SewerynKaminski> @tenebrousedge hmmm, you specify the type once :)
<FromGitter> <Blacksmoke16> `IO` defines `each_char`/`each_line`
<FromGitter> <ilanpillemer> gets(delimiter)
<FromGitter> <tenebrousedge> you could define an `Iterator`
<FromGitter> <ilanpillemer> `next = gets(",", chomp = true)`
<FromGitter> <ilanpillemer> this works
<FromGitter> <ilanpillemer> with a while loop until its `nil`
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da369cc57c2517c6a00f9b7]
<FromGitter> <Blacksmoke16> @SewerynKaminski https://play.crystal-lang.org/#/r/7sp9
<FromGitter> <Blacksmoke16> er maybe add the `.to_a` at the end
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7spg
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
absolutejam4 has joined #crystal-lang
<FromGitter> <SewerynKaminski> @Blacksmoke16 I have a struct with 3 Int32, and I need array of this as a constants
dannyAAM has joined #crystal-lang
<FromGitter> <Blacksmoke16> got a playground link?
<FromGitter> <SewerynKaminski> @Blacksmoke16 yes i have, the map magic is enought, thx
<FromGitter> <Blacksmoke16> 👍
absolutejam4 has quit [Ping timeout: 240 seconds]
absolutejam4 has joined #crystal-lang
<FromGitter> <sam0x17> also I think someone earlier mentioned they needed cheap and/or free postgresql hosting? these guys are great https://www.elephantsql.com/plans.html
<FromGitter> <absolutejam_gitlab> so I went with pug.js
<FromGitter> <absolutejam_gitlab> seems much nicer so far
<FromGitter> <absolutejam_gitlab> speaks to my yaml engineer heart
<FromGitter> <absolutejam_gitlab> Where's the data classes link that was posted yesterday?
<FromGitter> <absolutejam_gitlab> That might be a good option for @SewerynKaminski
<FromGitter> <absolutejam_gitlab> or using structs/`record`
<FromGitter> <absolutejam_gitlab> I was looking for the same kinda thing after playing with Go & Elixir struct literals (eg. `Foo{bar: "Baz"}`)
<FromGitter> <tenebrousedge> maybe an `enum` too, if that would make sense
<FromGitter> <tenebrousedge> it has `from_values` already
<FromGitter> <Blacksmoke16> `from_value`*
<FromGitter> <ImAHopelessDev_gitlab> Enums in Crystal are a facade. You are forced to capitalize the first letter of the enum value, but then are screwed in a case when statement. Because only the lowercase shorthand notation is available (the best kind). Which doesn't match the actual value of the Enum itself (causes ambiguity)
<FromGitter> <absolutejam_gitlab> Huh?
<FromGitter> <ImAHopelessDev_gitlab> @absolutejam_gitlab I made an issue about it here if you are interested https://github.com/crystal-lang/crystal/issues/8244
<FromGitter> <absolutejam_gitlab> Why not `when CMD::XFER`?
<FromGitter> <tenebrousedge> you can also use the capitalized form ⏎ https://crystal-lang.org/reference/syntax_and_semantics/enum.html
<FromGitter> <tenebrousedge> see Usage
<FromGitter> <ImAHopelessDev_gitlab> Not short-handly you can't
<FromGitter> <absolutejam_gitlab> seems like a non-issue
<FromGitter> <absolutejam_gitlab> You're not calling a method, you're accessing a constant
masterdonx2 has joined #crystal-lang
<hypercore> hello y'all, made some progress with the buildpack deployment, now i get this error (https://paste.ubuntu.com/p/8TXpqPsQm2/) "Failed to raise an exception: END_OF_STACK"
<hypercore> any idea what could be causing this?
MasterdonX has quit [Ping timeout: 268 seconds]
<hypercore> there's a similar error here (https://github.com/luckyframework/lucky/issues/775), but i have set SEND_GRID_KEY, and the other required env variables
gangstacat has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> @absolutejam_gitlab its just girng being girng
<FromGitter> <ilanpillemer> enums are cumbersome with all that `::`
<FromGitter> <tenebrousedge> well, there is the implicit object syntax with the predicate methods
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da37cd989acff6ff5ed745e]
<FromGitter> <Blacksmoke16> can be a lot of typing if they're namespaced deeploy, but can always alias it
<FromGitter> <absolutejam_gitlab> Are they created automatically?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <absolutejam_gitlab> Cool
<FromGitter> <absolutejam_gitlab> I don't use a lot of enums
<FromGitter> <Blacksmoke16> is an rfc about changing it a bit tho https://github.com/crystal-lang/crystal/issues/8000
<FromGitter> <tenebrousedge> hmm
<FromGitter> <absolutejam_gitlab> Doesn't using symbols add a bit less typo-safety?
<FromGitter> <tenebrousedge> seems so
<FromGitter> <absolutejam_gitlab> It's funny because in a language like Crystal, I really appreciate the safety aspects
<FromGitter> <absolutejam_gitlab> in Elixir I'm just dynamically dispatching stitched strings and all sorts
<FromGitter> <ilanpillemer> well I am now doing that in Crystal as its nicer
<FromGitter> <ilanpillemer> I just deleted all the enums
<FromGitter> <ImAHopelessDev_gitlab> > I just deleted all the enums ⏎ ⏎ ((https://forums.d2jsp.org/html/emoticons/drool.gif))
<FromGitter> <absolutejam_gitlab> it'd be nice if you could leverage the compiler to help you catch exceptions in some form
<FromGitter> <absolutejam_gitlab> as in, actual exception types
<FromGitter> <ilanpillemer> I am also adding methods to Nil so I dont have to keep doing Nil checks
<FromGitter> <Blacksmoke16> You can add type restrictions to rescue blocks
<FromGitter> <absolutejam_gitlab> Golang gives you multiple return values, one of which is normally an error. elixir usually gives you pattern matching on `{:ok, foo}` or `{:error, foo}`
<FromGitter> <absolutejam_gitlab> Yeah, but even perhaps a warning
<FromGitter> <Blacksmoke16> So they only handle exceptions of that type
<FromGitter> <ilanpillemer> the last one in Go as the error
<FromGitter> <absolutejam_gitlab> 'method food can throw SomeException but no catch block matches`
<FromGitter> <ilanpillemer> and 1.13 lets you wrap errors now
<FromGitter> <absolutejam_gitlab> Well yeah, I just meant there's not always an error returned but it's idiomatic
<FromGitter> <ilanpillemer> and context as first
<FromGitter> <absolutejam_gitlab> even as much as generated documentation I guess
<FromGitter> <absolutejam_gitlab> and yeah @Blacksmoke16, I mean the compiler hinting towards that
<FromGitter> <Blacksmoke16> ah ok
<FromGitter> <ilanpillemer> hmm.. you can’t `case self`?
alexherbo261 has joined #crystal-lang
<FromGitter> <tenebrousedge> can you `case self.dup` ?
<FromGitter> <ilanpillemer> no
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/7154 @absolutejam_gitlab
<FromGitter> <tenebrousedge> 👀
<FromGitter> <tenebrousedge> can you `case a = self` or `self.dup` ?
<FromGitter> <ilanpillemer> maybe its something else in the syntax
<FromGitter> <ilanpillemer> let me try it differently
<FromGitter> <Blacksmoke16> `case self` should work, got an example?
<FromGitter> <ilanpillemer> Ok. you can
alexherbo26 has quit [Ping timeout: 268 seconds]
<FromGitter> <tenebrousedge> kk
<FromGitter> <absolutejam_gitlab> ffs I just tried to click your link
<FromGitter> <absolutejam_gitlab> and clicked my own username 3 times
<FromGitter> <absolutejam_gitlab> WHY DOES HIS LINK HAVE MY FACE
<FromGitter> <Blacksmoke16> pro
<FromGitter> <Blacksmoke16> could be something added to crystal docs, would at least help to see what possible things could be handled
<hypercore> anyone know?
<FromGitter> <ilanpillemer> why is this not interpolating?
<FromGitter> <ilanpillemer> `result = "{#x},{#y}”`
<FromGitter> <Blacksmoke16> its `#{x}`
<FromGitter> <absolutejam_gitlab> `#{x},#{y}`
<FromGitter> <absolutejam_gitlab> beat me to it
<FromGitter> <Blacksmoke16> 😉
dwdv_ has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> :)
f1reflyylmao has quit [Quit: bye fags]
f1refly has joined #crystal-lang
ht__ has quit [Quit: ht__]
<FromGitter> <ilanpillemer> I htink my brain is broken
<FromGitter> <tenebrousedge> probably
<hypercore> anyone seen "remote: Invalid memory access (signal 11) at address 0x7f69a0879da8" before?
<FromGitter> <tenebrousedge> that's a common one
<FromGitter> <tenebrousedge> were you working with an array?
<FromGitter> <ilanpillemer> hypercore, I think thats a segfault
<hypercore> i get it when i run lucky (framework) via a buildpack
<hypercore> It happens sometime after the shards are installed, but it ddoesn
<hypercore> doesn't give any more information than that
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
<FromGitter> <tenebrousedge> this is probably why I like docker
<hypercore> i'm trying to come up with a simple deployment method for my lucky apps, using dokku right now, maybe it would work on heroku
<hypercore> i don't feel like i know docker well enough to be comfortable using it in this regard
<bougyman> you don't have to
<bougyman> docker is a breeze with a very low learning curve for such things.
<FromGitter> <ilanpillemer> docker is a dodlle
<hypercore> bougyman: can i do git-based deploy using docker?
alexherbo261 has quit [Ping timeout: 240 seconds]
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
alexherbo261 has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<FromGitter> <ilanpillemer> ok.. found my mind and managed out it out in Crystal
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<FromGitter> <ilanpillemer> part two had me confounded until I realised I had misunderstood the question.
<FromGitter> <ilanpillemer> man.. I was so slow to solve this
return0e has quit [Remote host closed the connection]
<FromGitter> <ilanpillemer> puzzles are so humbling when learning a language
return0e has joined #crystal-lang
return0e has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> whats the goal?
<FromGitter> <ilanpillemer> Saving Christmas for the Easter Rabbit
<FromGitter> <ilanpillemer> I had to find Easter Bunny HQ, to retrieve the starts the rabbit stole that power the sleigh.
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <ilanpillemer> I would like to get 50 puzzles solved by Dec 1
<FromGitter> <Blacksmoke16> prob could use char literal for your case statement
<FromGitter> <ilanpillemer> I had an enum… but too much typing
<FromGitter> <Blacksmoke16> `.r?` is too much? :p
<FromGitter> <ilanpillemer> I was doing direction::N
<FromGitter> <Blacksmoke16> if using the enum in a case you can use the shorthand method, which in that case would be `.n?`
<FromGitter> <ilanpillemer> that is less typing, maybe that would have been fine then
<FromGitter> <ilanpillemer> I like succint
<FromGitter> <Blacksmoke16> also could have defined the bigger case as instance methods within the enum vs reopening string
<FromGitter> <absolutejam_gitlab> I thought `@@` was a class var/?
<FromGitter> <ilanpillemer> there is probably a way of using a hash map?
<FromGitter> <ilanpillemer> module
<FromGitter> <Blacksmoke16> no its a class var
<FromGitter> <Blacksmoke16> why?
<FromGitter> <ilanpillemer> module
<FromGitter> <Blacksmoke16> works the same in a module
<FromGitter> <ilanpillemer> you cant use @ in a module
<FromGitter> <absolutejam_gitlab> I've never seen it used in a module, on consts
<FromGitter> <absolutejam_gitlab> only*
<FromGitter> <ilanpillemer> then check this out
<FromGitter> <absolutejam_gitlab> Crystal needs a first class single-line method body
<FromGitter> <absolutejam_gitlab> like Elixir has ⏎ ⏎ ```def foo, do: stuff``` [https://gitter.im/crystal-lang/crystal?at=5da3a771894dee56e53a27ed]
<FromGitter> <absolutejam_gitlab> Although, the former is actually a macro for the latter IIRC
<FromGitter> <Blacksmoke16> `def foo; stuff; end` :p
<FromGitter> <Blacksmoke16> could always make a macro to do it for you
<FromGitter> <absolutejam_gitlab> Yeah but it's not as nice
alexherbo261 has quit [Ping timeout: 276 seconds]
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <absolutejam_gitlab> What's the benefit of using a module in this case?
<FromGitter> <Blacksmoke16> why not just do `case @@token`?
<FromGitter> <ilanpillemer> when I was started writing it, I did not know yet if there would be things that didnt need `@@token`
<FromGitter> <absolutejam_gitlab> I generally sway to using modules vs. classes if I'm just using the class (not instances), but this seems like an anti-pattern
<FromGitter> <Blacksmoke16> ah, fair enough
<FromGitter> <ilanpillemer> I have been swaying towards modules
<FromGitter> <Blacksmoke16> not really any diff than doing everything at the top level
<FromGitter> <absolutejam_gitlab> But if I'm using a module (vs class instances), I wouldn't share state
<FromGitter> <absolutejam_gitlab> or I'd share state in a specific way
<FromGitter> <ilanpillemer> I just treated the module as the unit
<FromGitter> <absolutejam_gitlab> I mean, if it's 'just because' then fair enough
<FromGitter> <absolutejam_gitlab> I didn't know if you were doing it for a reason
<FromGitter> <ilanpillemer> havnt been doing that much OO in ages
<FromGitter> <ilanpillemer> so just defaulted to modules as a result
<FromGitter> <absolutejam_gitlab> fair enough
<FromGitter> <absolutejam_gitlab> Have you done any/much Elixir?
<FromGitter> <ilanpillemer> no. played a big with Erlang about 18 months ago
<FromGitter> <ImAHopelessDev_gitlab> this (https://www.youtube.com/watch?v=fpmTe3TDdVU) is how my brain feels when using a functional language :P
<FromGitter> <ilanpillemer> like some guy using gram marly?
<FromGitter> <ImAHopelessDev_gitlab> 😆
<FromGitter> <absolutejam_gitlab> I like funcional
<FromGitter> <absolutejam_gitlab> functional too
<FromGitter> <absolutejam_gitlab> it's easy to reason about
<FromGitter> <absolutejam_gitlab> I mean, not haskell level functional
<FromGitter> <ilanpillemer> well I like languages that provide tco
<FromGitter> <absolutejam_gitlab> Read that as 'total cost of ownership' at first
<FromGitter> <absolutejam_gitlab> I played with Clojure before Elixir but it seemed too toy-like
<FromGitter> <absolutejam_gitlab> Like most LISPs are academic more than anything
<FromGitter> <absolutejam_gitlab> I know Clojure is relatively big and Rich Hickey is a genius
<FromGitter> <absolutejam_gitlab> but I was swayed by Elixir
<FromGitter> <absolutejam_gitlab> > Jennifer uses Sam for running tasks pertinent to ORM operations.
<FromGitter> <absolutejam_gitlab> Hey, let's name all of our shards after people. Totally not confusing
<FromGitter> <Blacksmoke16> :p
<FromGitter> <ilanpillemer> improved the case statement for directions
<FromGitter> <Blacksmoke16> i suggest granite if you're going to be doing anything with annotations
<FromGitter> <ilanpillemer> sam is a text editor
<FromGitter> <Blacksmoke16> its similar to rake
<FromGitter> <ilanpillemer> I am going to be looking at Pony
absolutejam4 has quit [Ping timeout: 265 seconds]
<FromGitter> <ilanpillemer> day 2 for tomorrow evening
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
<FromGitter> <Blacksmoke16> what are you guys' opinions on like `def self.from_type(type : Typ)` vs `def initialize(type : Typ)`
<FromGitter> <ilanpillemer> initialize is hard to type
<FromGitter> <Blacksmoke16> and thus ofc `MyClass.new typ` vs `MyClass.from_type typ`
<FromGitter> <ilanpillemer> new is easy to type
<FromGitter> <Blacksmoke16> hm?
<hypercore> are you guys using crystal as your main dev language?
<FromGitter> <Blacksmoke16> naw
<FromGitter> <ilanpillemer> no
alexherbo261 has joined #crystal-lang
alexherbo261 is now known as alex```
<alex```> re
<alex```> it's not really related to crystal, I would say thanks to someone in a credits section
<alex```> is the sentence correct "@ul, for his advice and proofreading, especially on the early stages"?
<alex```> (i'm not english native)
<FromGitter> <tenebrousedge> works for me
<FromGitter> <tenebrousedge> 👍
<alex```> does "on" or "in" change something?
<FromGitter> <tenebrousedge> "in" is probably better
<FromGitter> <tenebrousedge> both are grammatical
<alex```> I was hesitant on that :D
<alex```> and "stage" is better singular or plural form, what is the difference?
<FromGitter> <tenebrousedge> stages should be pluralized
<FromGitter> <tenebrousedge> "early-stage" is found as an adjective
<FromGitter> <tenebrousedge> "an early-stage product"
<alex```> oh
<FromGitter> <tenebrousedge> but the noun form is an uncountable plural
<alex```> I've read somewhere adjective do not take a hyphen "-"
<FromGitter> <tenebrousedge> that would not be correct. "red-hot", "late-breaking", "free-flowing"
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang