<FromGitter>
<watzon> @bestwebua you can specify default arguments like this `def foo(bar = 2)` and then call them like this `foo(bar: 3)`. If you want any arguments to only be named, and not named or positional, you can do this `def foo(positional_argument, *, named_arg = 3, another = "foo")`
<FromGitter>
<watzon> The `*` means "anything after me is named"
<FromGitter>
<tenebrousedge> something that's not public is to some degree considered an "implementation detail", which is subject to change without notice
<FromGitter>
<tenebrousedge> a public interface is in some senses a contract between your code and other code that uses it
<FromGitter>
<Blacksmoke16> like this works just fine
<FromGitter>
<girng> i think this is more of a feature if working in large teams or people, you might want some stuff protected
<FromGitter>
<girng> but for 1 man show, where 1 dev knows his code, i think it's silly af
<FromGitter>
<tenebrousedge> say you're working with a bunch of similar APIs, you would probably want an abstract `BaseAPI` class with a protected `base_url` property
<FromGitter>
<Blacksmoke16> @girng i used the inheritance and stuff in the OOP approach to that guys game
<FromGitter>
<Blacksmoke16> so you only needed 1 `def detail` to handle each attribute
<FromGitter>
<girng> @tenebrousedge that makes sense
<FromGitter>
<girng> @tenebrousedge good use case example
<FromGitter>
<girng> @Blacksmoke16 yeah, great work doing that for that guy. that was very cool
<FromGitter>
<Blacksmoke16> is there any concept of output streaming in crystal?
<FromGitter>
<Blacksmoke16> doing a process.run on a process that will stream output as its ready, but the process is finishing and closing the output causing a broken pipe error
<FromGitter>
<Blacksmoke16> trying to think of what my options are...
<FromGitter>
<Blacksmoke16> besides just catching the exception and printing the output
alex`` has joined #crystal-lang
<FromGitter>
<j8r> you can specify the IO
<FromGitter>
<j8r> maybe with no buffer to solve your problem
<FromGitter>
<Blacksmoke16> what would that look like?
<FromGitter>
<Blacksmoke16> currently im just doing like
<FromGitter>
<Blacksmoke16> ` run = Process.run("jq", args, input: input.rewind, output: output, error: err)` ⏎ where `output` is an `IO::Memory`
<FromGitter>
<j8r> then you can't read the `output`, because it's closed?
<FromGitter>
<j8r> ...I'm curious, why are you using jq?
<FromGitter>
<Blacksmoke16> making a wrapper that allows giving it json/yaml (soon xml), transform it via jq, then output to json/yaml/xml
<FromGitter>
<j8r> this is to support for the jq syntax, can't be done in pure Crystal?
<FromGitter>
<Blacksmoke16> im sure it could, but that would be a lot of work
<FromGitter>
<Blacksmoke16> for something that is already done and done well
<FromGitter>
<j8r> what would be `args`, accessing to an arbitrary key?
<FromGitter>
<j8r> What will be hard to do is all the filters :/
<FromGitter>
<Blacksmoke16> args would just be the args passed to the binary
<FromGitter>
<Blacksmoke16> and yea, jq has a bunch of shit
<FromGitter>
<j8r> just curious what 's the usage of jq you will do
<FromGitter>
<j8r> because accessing to a dynamic key path is already possible in Crystal, if that's all you want
<FromGitter>
<Blacksmoke16> the main use case that started the idea was at work we have some feeds that allow partners to consume data from them
<FromGitter>
<Blacksmoke16> currently we're using jq to format the data into the format the partner wants from a master list of data
<FromGitter>
<Blacksmoke16> a new partner wanted xml, so ideally having a single binary that could do all the processing using shared filters and output to whatever format we want would be ideal
<FromGitter>
<Blacksmoke16> vs having separate logic/libs etc for json vs xml
<FromGitter>
<j8r> ok i sea
<FromGitter>
<Blacksmoke16> but current lib we're using is that python one, and its not performant
<FromGitter>
<Blacksmoke16> which i was like, hey i could do this in crystal and get a big boost in perf
<FromGitter>
<Blacksmoke16> :P
<FromGitter>
<j8r> not possible to avoid closing the IO for jq?
<FromGitter>
<Blacksmoke16> just to be clear, the issue is only when using the `--stream` command and the `inputs` options, which makes jq do some work, then pause for a bit, then close
<FromGitter>
<Blacksmoke16> but i think the `Process.run` when its done closes the output soon as it gets the data
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> causing the error, but still has the correct data
<FromGitter>
<Blacksmoke16> ideally id like to support jq `1:1` but for initial version its not a big deal imo
<FromGitter>
<cfsamson> Is a pointer to a class a fat pointer in Crystal?
<FromGitter>
<cfsamson> It looks like it, though...
<FromGitter>
<Blacksmoke16> idk what that means so ill leave that for someone else
<FromGitter>
<j8r> AFAIK Process.run don't close IO
<FromGitter>
<Blacksmoke16> it does because of `#wait`
<FromGitter>
<Blacksmoke16> and notice you see the output, then there is that delay until process finishes
<FromGitter>
<Blacksmoke16> which that delay is the issue id imagine
alex`` has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter>
<girng> that json is huge wtf
<FromGitter>
<j8r> ... :o
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter>
<watzon> That is one massive fucking file
<FromGitter>
<Blacksmoke16> this is the thing that took the python thing 13min and 20 gigs of ram to do
alex`` has joined #crystal-lang
<FromGitter>
<girng> LOOOOOOOOL
<FromGitter>
<Blacksmoke16> that jq does in like 2 sec using 20mb of ram
<FromGitter>
<girng> impressive
<FromGitter>
<Blacksmoke16> yea it does something with the input so it streams it in, vs loading it all into memory
Jolav has joined #crystal-lang
Jolav has quit [Remote host closed the connection]
<FromGitter>
<watzon> I feel like I've asked this before, but is it possible to build a binary together with dependencies like libssl?
<jokke>
you mean static linking?
<jokke>
watzon, you could try with alpine. I've statically linked several projects in alpine
<jokke>
best build in a docker image
<FromGitter>
<watzon> Good idea
moei has quit [Quit: Leaving...]
<jokke>
i maintain an alpine based crystal image
<jokke>
jreinert/crystal-alpine
<jokke>
but there has been some kind of regression in alpine that causes it to fail decoding utf8
<jokke>
so currently only jreinert/crystal-alpine:0.27.0 and lower work
<FromGitter>
<watzon> Well that sucks
<jokke>
yeah :/
<jokke>
it also happens in a fresh alpine image
_whitelogger has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
<rkeene>
What I did when I wanted to statically link was tell Crystal I was cross-compiling, then it gave me object files and I could do the final linking myself