ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.21.1 | Fund Crystal's development: | Paste > 3 lines of text to | GH: | Docs: | API: | Logs:
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 260 seconds]
<travis-ci> crystal-lang/crystal#e747c3d (master - Add File.touch and FileUtils.touch methods (#4069)): The build passed.
<DeBot> (Add File.touch and FileUtils.touch methods)
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
miketheman_ has joined #crystal-lang
miketheman_ has left #crystal-lang [#crystal-lang]
<crystal-gh> [crystal] bcardiff closed pull request #4112: Formatter: fixed private constants alignment (master...fix/crystal-format/private-constant)
akwiatkowski has quit [Ping timeout: 260 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<travis-ci> crystal-lang/crystal#2065548 (master - Merge pull request #4112 from MakeNowJust/fix/crystal-format/private-constant): The build passed.
<DeBot> (Formatter: fixed private constants alignment)
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
bjz has joined #crystal-lang
<FromGitter> <jipiboily> If you folks want to see some Crystal screencasts: - only paid customers can vote, though. They produce high quality content (creator of Elixir Sips) ⏎ ⏎ Disclaimer: one of the co-founders is a friend
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <jipiboily> Is there a way to have a begin/rescue block at the app level? catch everything?
<FromGitter> <jipiboily> Would be great for Bugsnag (or others)
bjz has joined #crystal-lang
<FromGitter> <jipiboily> I guess I’ll need a Kemal middleware in my case and I’ll be alright
bjz has quit [Ping timeout: 260 seconds]
<FromGitter> <jipiboily> pretty easy, nevermind!
<FromGitter> <jipiboily> the basic idea is: ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <jipiboily> and replacing `puts "Doing some custom stuff here”` by the call to bugsnag
alibby1 has quit [Quit: Leaving.]
alibby1 has joined #crystal-lang
endou_ has joined #crystal-lang
endou has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
Renich has quit [Ping timeout: 260 seconds]
<FromGitter> <Zhomart> Hello, is there immutable Array in crystal? Tuple doesn't work for me because it's format should be known in compile time.
<FromGitter> <Zhomart> ok, found, StaticArray :)
<FromGitter> <Zhomart> Ok, StaticArray doesn't work. It asks shape to be defined in compile time.
bjz has joined #crystal-lang
<FromGitter> <schoening> @Zhomart omg dude! I hadnt found the static array yet. Thanks mate :D
<FromGitter> <bcardiff> StaticArray is stack allocated, but it is mutable
<FromGitter> <bcardiff> If you want immutable there is at least a shard for that:
alibby1 has quit [Quit: Leaving.]
<FromGitter> <Zhomart> @bcardiff thanks for shard. But I decided to use `Slice`. I needed some collection to store shape of an array, e.g. `[2,3,6]` using `struct`.
<FromGitter> <bcardiff> Slice is basically a pointer with a limit. It's still mutable
<FromGitter> <jipiboily> @bcardiff thanks for Crystal, haven’t so much fun working on code in a long time :)
<FromGitter> <jipiboily> Damn easy to pickup (for an experienced Ruby dev at least).
<FromGitter> <jipiboily> ok, going to bed now; was fun building a shard and a kemal middleware in the last hour. :wave:
<FromGitter> <schoening> @jipiboily also for non rubyist. I never used a white space language and had a completed project in 3 days :p its awesome
<FromGitter> <Zhomart> That's true. Sorry, I made mistake on my first question.
<FromGitter> <schoening> Been thinking for years about how I would want a programming language to be designed if I made one.. turns out that my ideas were pretty much ruby / crystal hehe xD
Renich has joined #crystal-lang
<FromGitter> <bcardiff> I'm glad you all are having fun. But there are many people to thank to. I am just the one online right now :-P.
<FromGitter> <schoening> One thing tho.. I wish there was some easy distinction between stack and heap allocated constructors :/ I'm sure there is a reason for them all to use the "new" method. But it also would be nice if there was a distinction. Perhaps and StackAllocatedClass.alloc - does that makes sence?
<FromGitter> <bcardiff> @Zhomart actually Slice can be readonly, but that usage is a bit internal.
<FromGitter> <bcardiff> @schoening that distinction is Class (reference types) vs Struct (value types).
<FromGitter> <bcardiff> but the constructors are called .new always, otherwise some polimorphic code is almost impossible to write.
pawnbox has joined #crystal-lang
<FromGitter> <schoening> Thanks for clearing up why things are they way they are. I suppose I would like a method for structs that invokes new but with a different name as an option :p ⏎ ⏎ But the distinction you mention is only something I can be aware of by memorizing the language, I was talking syntax wise there is no difference, right?
<FromGitter> <bcardiff> I don't follow. I mean that in having a unified way to create instances, whether stack or heap, is convenient for writing code like `` where `T` could be a type variable. If there will be different on struct and classes you will need to make a distinction on lot's of places
pawnbox has quit [Ping timeout: 240 seconds]
<FromGitter> <schoening> Yeah ok, I get that it's convinient and probably best this way. I'm only bringing it up because I occasionally get confused if I am allocating on the heap or stack and I need to check the manual to be sure. And thats not terrible ofc, but thats why I said it could be nice for a noob like me to know where things are allocated by just skimming through my code
<FromGitter> <schoening> I just never had the mighty power of being able to choose between stack or heap memory :p so now I am trying to do as much as possible on the stack!
<FromGitter> <Zhomart> Is it ok to store huge data in `Slice`?
Renich has quit [Quit: Renich]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]
bungoman has joined #crystal-lang
pawnbox has joined #crystal-lang
bungoman_ has quit [Ping timeout: 246 seconds]
<FromGitter> <Zhomart> What if `Enumerable#map` returns `Iterable` instead of an `Array`?
pawnbox has quit [Ping timeout: 260 seconds]
<FromGitter> <Zhomart> @bcardiff omg, how did I miss it, thanks..
<FromGitter> <bcardiff> welcome. and regarding Slice, it depends on your memory. It is a countinous chunk of memory.
<FromGitter> <bcardiff> going offline soon 2am here :-)
<FromGitter> <Zhomart> @bcardiff good night. Thank you for helping here...
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tzekid has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
Qchmqs has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
<FromGitter> <sdogruyol> @jipiboily there's already one for Sentry
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 268 seconds]
akwiatkowski has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Client Quit]
splitty_ has quit [Read error: Connection reset by peer]
alibby has joined #crystal-lang
splitty_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
bjz has joined #crystal-lang
tzekid has quit [Quit: Leaving]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
braidn[m]1 has quit [Read error: Connection reset by peer]
braidn[m] has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
<FromGitter> <sdogruyol> nice to see someone trying faster hash implementation for Crystal :clap:
<FromGitter> <yxhuvud> Hey, it is not functioning yet :)
<FromGitter> <yxhuvud> I'm basically copying the Ruby implementation line for line now (though with constant index size for now).
<FromGitter> <yxhuvud> And I'm less than 1/3 through the file so don't expect anything soon..
<RX14> i'd love to see some benchmarks with different hash implementation
<RX14> iirc there's been a lot of cool hasmap impls floating around recently
<RX14> for example rust
<FromGitter> <yxhuvud> Yeah that would be the next step after it actually works. Preferably in a pluggable way that is easy to expand.
<FromGitter> <sdogruyol> @yxhuvud it's a good thing to start :)
<FromGitter> <yxhuvud> It is even better to finish!
<FromGitter> <sdogruyol> yup, you've done the hard part IMHO :)
<FromGitter> <agibralter> I asked this a few days ago (sorry to repeat, but it was quiet then). Could someone tell me if this looks like a legit way to run a process with crystal and pass a sigint to it?
<RX14> looks right
<FromGitter> <sdogruyol> seems fine
<FromGitter> <sdogruyol> i've done something similar before
<FromGitter> <sdogruyol> though i was using `at_exit` with trap
<FromGitter> <agibralter> ah cool, thank you!
<FromGitter> <sdogruyol> :+1:
<FromGitter> <agibralter> Just curious, is there a preferred CLI library these days?
<FromGitter> <agibralter> I've been messing around with
<FromGitter> <sdogruyol> yeah that one is pretty well maintained
<RX14> that one seems to be the most feature complete
<RX14> however I *really* dislike it's DSL
<FromGitter> <agibralter> yeah, same
<FromGitter> <agibralter> Subcommand => Supercommand
<RX14> it's implementation is macro hell, and why on earth does it use specially named classes?
<FromGitter> <sdogruyol> not maintained but should be easy to update
<RX14> that one doesn't do completion generation
<FromGitter> <agibralter> lol @ macro hell
<RX14> it is macro hell
<RX14> the source code burns my eyes
<FromGitter> <agibralter> :laughing:
<FromGitter> <sdogruyol> everyone should watch @asterite 's talk on macros
<FromGitter> <agibralter> Ohh commander looks nicer
<RX14> this is why we have the "do it without macros first" rule
<FromGitter> <sdogruyol> there are 5 rules and the first 3 are "don't use macros"
<RX14> it forces you to write normal code then identify the bits which can't be deduplicated without macros
<FromGitter> <agibralter> Like Ruby and most metaprogramming
<FromGitter> <sdogruyol> indeed :)
<FromGitter> <sdogruyol> i'm glad that we don't have `send` in Crystal
<FromGitter> <agibralter> :smile:
<FromGitter> <agibralter> Anyone know why shards.lock doesn't store the sha?
<FromGitter> <sdogruyol> is it necessary?
<FromGitter> <sdogruyol> Gemfile.lock also doesn't store sha (as i remember)
<FromGitter> <drosehn> I like the meta-programming ability of ruby, but I use it very sparingly.
<FromGitter> <agibralter> Well... if someone force pushes a version of a github dependency, won't that be able to change the lib out from under you?
<FromGitter> <agibralter> Gemfile.lock does for github based dependencies
<FromGitter> <sdogruyol> ah yeah
<FromGitter> <sdogruyol> @agibralter you are right
<FromGitter> <agibralter> I guess it's not the end of the world... someone could force push a version of a gem to Rubygems and that would have the same effect
<FromGitter> <yxhuvud> My metaprogramming in Ruby is mostly limited to generating methods and instace_exec. Crystal have those covered.
pawnbox has quit [Remote host closed the connection]
<RX14> i'd prefer if shards.lock just stored sha1 too
pawnbox has joined #crystal-lang
<RX14> i wonder if theres a reason why it does not
<Papierkorb> *sha256
<RX14> git uses sha1
<RX14> shards uses git
<RX14> it would be sha1
<RX14> the commit hash to check out
<Papierkorb> which is hopefully remedied in a few years
<RX14> i doubt it
<FromGitter> <sdogruyol> same
<FromGitter> <sdogruyol> it's so highly coupled and hard to remove
<RX14> linus seems to hold the opinion that the current sha1 weakness doesn't compromise git
<RX14> and i tend to agree with him
<Papierkorb> Unlikely it is
<FromGitter> <agibralter> yeah...
<Papierkorb> But a shatter attack has been demonstrated on Torrent
<Papierkorb> So it's only a question of time until someone does it with Git
<FromGitter> <sdogruyol> reminded of torrent i recall that you were writing a torrent shard :P
<Papierkorb> I did a few months back
<Papierkorb> Yeah SHA-1 is deeply rooted into anything it does
<RX14> even md5 is still preimage resistant
<RX14> and it seems that the current hypothesis is that a preimage attack is required to compromise git
<FromGitter> <agibralter> Hmm how does (in README) know that the `kill` command is called `kill`?
<FromGitter> <agibralter> Does it parse `cmd.use = "kill <pid>"` ?!
<FromGitter> <sdogruyol> i hope it doesnt
<Papierkorb> Why parse?
<FromGitter> <agibralter> Because it doesn't look like the string `"kill"` is specified anywhere
<Papierkorb> No need to parse, that's literally printed out the way the programmer put it in
<RX14> yup
<RX14> it uses use
<RX14> which is weird
<FromGitter> <agibralter> Yeah... really janky
bjz has joined #crystal-lang
<FromGitter> <sdogruyol> jesus that's weird
<FromGitter> <agibralter> :disappointed:
<RX14> they're all bad :(
<RX14> i settled on mosop/cli
<FromGitter> <sdogruyol> @RX14 how's crane going :P
<FromGitter> <agibralter> lol, yeah
<RX14> it's uhh
<FromGitter> <sdogruyol> reading posts about rust cross-compiling e.g really makes me want to have the same ease of use in Crystal :P
<RX14> not done much work this week
bjz_ has quit [Ping timeout: 256 seconds]
<RX14> i'll probably do some today
<FromGitter> <sdogruyol> :+1:
<RX14> i'm thinking of writing a proposal to completely rework File and Dir
<RX14> my idea would be to have a Path class which represents a filesystem path, which doesn't have to be valid
<RX14> then we provide super easy ways to work with paths (like
<FromGitter> <schoening> I wish I was better at the language. I would like to help out making the api more descriptive :/
<FromGitter> <sdogruyol> @RX14 "doesn't have to be valid" this makes me feel uncomfortable
<FromGitter> <sdogruyol> @schoening you still can do a lot of things :)
<RX14> as in
<RX14> the file or dir doesn't have to exist
<RX14> bit it would have to be valid in that it could theoretically exist
<FromGitter> <schoening> @sdogruyol give me some examples :) Id like to see if I can help out in my spare time
<RX14> I'd provide to_file and to_dir methods on Path, which would return File or Dir instances for the path
<RX14> checking that the File or Dir exists and is a file or dikrectory of course
<RX14> and those File or Dir classes would provide ways to do file-specific or dir-specific operations
<RX14> no more File.join, you'd start with a then append path segments (dir + "../foo/bar" possibly?)
<RX14> it'd get rid of FileUtils too
<RX14> deleting things would be done using delete, if you want recursive use recursive: true
<RX14> instead of being forced to use FileUtils.rm_rf
akwiatkowski has quit [Ping timeout: 260 seconds]
<RX14> @sdogruyol should crane implement a syntax like `crystal @0.21.0 run xxx`, and if so what should the syntax be
<RX14> because rustup seems to do that
<FromGitter> <sdogruyol> that's neat yeah
<FromGitter> <sdogruyol> if you don't have an active installation that's the way to run stuff
pawnbox has quit [Ping timeout: 260 seconds]
<RX14> i think @ syntax has shell escaping issues though
<RX14> oh no
<RX14> i'm wrong
<RX14> @ is OK
pawnbox has joined #crystal-lang
<RX14> @ is special in fish
<RX14> but lets pretend that fish shell users don't exist
<FromGitter> <sdogruyol> :)
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> @RX14 btw i also like `crenv` s way of `shell`, `local` and `global`
<FromGitter> <sdogruyol> WDYT?
<RX14> yeah
<RX14> global and local are fine
<RX14> but shell might have to go
<RX14> i won't implement it right away
<FromGitter> <sdogruyol> yeah it's not that useful anyway
<RX14> and just advise people to use crystal @foo
<RX14> instead
<FromGitter> <sdogruyol> global and local are OK
<RX14> and as you said
<FromGitter> <sdogruyol> yeah
<RX14> it's the least useful one
<FromGitter> <sdogruyol> idd
<Papierkorb> gem binstubs btw use `_VERSION_` as magic argument
<RX14> ??
<Papierkorb> $ pry _1.2.3_ --stuff-for-pry
<RX14> ehh
<RX14> i think @ is fine
<FromGitter> <sdogruyol> @ is good imho
<RX14> i'm unsure what to do about shards though
<RX14> do we manage shards as if it's tried to the crystal version?
<RX14> it seems to be the case at the moment
<RX14> but that seems inflexible and wrong
<FromGitter> <sdogruyol> why?
<FromGitter> <sdogruyol> each version has it's own shards sounds find
<FromGitter> <sdogruyol> fine*
<RX14> one day there will be a critical bug in the shards release, should we release a new crystal version with updated shards only?
<Papierkorb> yes, else you're restricting shards to use the oldest version of crystal
<RX14> huh?
<Papierkorb> "should we release a new crystal version with updated shards only?" What's wrong with it?
<RX14> locking 2 dependencies versions together is wrong, we should be able to manage shards and crystal versions independantly
<Papierkorb> shards the tool?
<RX14> they're not even locked together currently
<RX14> it just happens to be the case for people using the omnibus
<RX14> which isn't everybody
<RX14> Papierkorb, shards the tool, yes
<Papierkorb> no idea what omnibus is
<RX14> the compiled crystal release downloadable from github
<RX14> which contains shards as crystal deps
<Papierkorb> If I say "this project uses crystal version X", then I also want all of the dependencies to use a version that was built for that X
<Papierkorb> Else a later shards release breaks, knowingly or not, something and old projects break too.
<Papierkorb> ripping out shards is like ripping out rubygems from ruby
<Qchmqs> are shards binary ?
<FromGitter> <yxhuvud> But rubygems can be upgraded separately
<Qchmqs> or statically linked with the app ?
<RX14> shards are distributed as source
<Qchmqs> then you link static or dynamic ?
<RX14> we're talking about the shards executable, the actual commandline application itself
<RX14> link neither
<Qchmqs> can they be installed as binaries from an external package manager ?
<RX14> dependencies aren't linked against
<RX14> they're distributed as source and complied into 1 binary
<Qchmqs> so crystal binaries are fat
<RX14> yes
<Papierkorb> yxhuvud they can, but are they usually? Even bundler is about to support fixing the bundler version to be used because of this
<RX14> if that's the case, shards should use the same version number as the crystal release exactly
<Papierkorb> yes
Qchmqs has quit [Ping timeout: 240 seconds]
<RX14> i'll just leave out shards management for now
<RX14> and create an issue
<RX14> on the shards repo
Raimondi has quit [Ping timeout: 268 seconds]
pawnbox_ has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
<FromGitter> <tzekid> Hi there, newby here
<FromGitter> <tzekid> dunno if I'm missing something, but neither len("string"), nor "string".length are working ...
<FromGitter> <fridgerator> hello
<RX14> @tzekid the method is called size in crystal
<FromGitter> <tzekid> cheers ^^
<FromGitter> <ideasasylum> Is there a canonical s3 library for Crystal yet?
<FromGitter> <fridgerator> there are a couple of aws request signing libraries, but thats about it
<FromGitter> <fridgerator> as far as I know
<FromGitter> <ideasasylum> @fridgerator yeah, thanks. I've found and
<FromGitter> <ideasasylum> I'll need to check into what the differences are :confused:
<FromGitter> <fridgerator> I had better success with the second one
<FromGitter> <ideasasylum> :thumbsup:
<FromGitter> <schoening> What's the eta on 1.0 out of curiosity? 2020? (I'm not trolling, I assume this will take quite a while considering the current version number)
<FromGitter> <KCreate> They mention in one of the recent blog posts
<FromGitter> <KCreate> iirc
<FromGitter> <schoening> Oh. Ty. I'll take a look
<FromGitter> <schoening> Nice of you, thanks :D
<FromGitter> <schoening> Hahaha aw man.. with a title like that I do feel a bit like an idiot for asking for an eta xD
<FromGitter> <KCreate> well regarding they went from 0 to 0.21 within like 5 years, on might assume this rate of increase won't change
<FromGitter> <crisward> Node went from 0.11 to v 4.0 in a couple of months... version numbers are not always a good indicator, it took them years to get to 0.11
<FromGitter> <schoening> My god yes.. Node.js version numbers are crazy.
<FromGitter> <schoening> Was confused for ages by people arguing to use 4 vs 0.12 like.. what is this??
<FromGitter> <schoening> And in game development nothing ever leaves alpha or "green light" for a long time because then devs can wave bugs off as "we are still in development" xD
<FromGitter> <fridgerator> the early access plague...
<FromGitter> <fridgerator> i don't think its going anywhere anytime soon either
<FromGitter> <fridgerator> because people purchase
<FromGitter> <schoening> True
Ven has joined #crystal-lang
Ven is now known as Guest27220
<FromGitter> <sdogruyol> @RX14 thanks for being active on StackOverflow Crystal tag
<FromGitter> <sdogruyol> for anyone wants to contribute
sija has joined #crystal-lang
blufor has joined #crystal-lang
<RX14> @sdogruyol done some more work on crane :)
<FromGitter> <sdogruyol> @RX14 :+1:
<FromGitter> <sdogruyol> imma clone
<FromGitter> <sdogruyol> curious about this :P
Raimondi has joined #crystal-lang
<RX14> @sdogruyol that URL (especially the source) details what haskell decided to do to map the XDG data directories to windows
<Papierkorb> Is there a way to replace a part of a String with another string?
<RX14> gsub
<Papierkorb> By offset and length
<Papierkorb> There's no `#[]=` either
<Papierkorb> err immutable
<Papierkorb> but no #replace or so either
<RX14> str[0, index] + replacement + str[index + length, -1]
<Papierkorb> There it is #sub(range, ..)
<FromGitter> <sdogruyol> ugh
<FromGitter> <elorest> <RX14> <Papierkorb> Sorry I missed you guys responding yesterday. At first I thought it would be easy to just wrap libbluetooth as I've wrapped a couple of other c libraries in the last week and it worked fine. I can't seem to find any docs for libbluetooth though and I'm having a hard time finding where a lot of variable/pointer types/structs are even being defined.
<Papierkorb> elorest, /usr/include/libbluetooth hosts the header files. There aren't too many, so I'd just open them all in my editor. Really, I'd just grep (or w/e you like) for something I need, a structure definition or whatever, and then dig my way through until I'm satisfied
<Papierkorb> elorest, let me plug `the_silver_searcher`, which is the horrible package name (ArchLinux package name at least) for the `ag` tool, which is a insanely fast grep-for-code. libbluetooth isn't that big yet, but for bigger projects it quickly makes a huge difference in time needed for the search
<FromGitter> <elorest> Ok thanks. It seems unclear without documentation or examples what methods I would actually even call for what... Also I'm already using the silver searcher for everything. Thanks.
<shelvacu> why is ag faster than regular grep?
<Papierkorb> different engine and everything, also does parallel search and has tons of other optimizations
<FromGitter> <elorest> It's written in c...
<FromGitter> <elorest> Are you the author?
<Papierkorb> No
<Papierkorb> Usually, for a sufficiently large code base, installing that thing and using it to search for X is still faster than grepping for the same X
<RX14> grep's pretty fast...
<RX14> i guess me having an SSD skews that quite a bit
<Papierkorb> My sources are all on SSDs, have been for years, and there's still a noticable difference
<RX14> there was that other rust-based tool too wasn't there
tax has joined #crystal-lang
sz0 has joined #crystal-lang
tax has quit [Quit: Leaving]
<FromGitter> <zatherz> is there a proper way to handle pipes in crystal?
<FromGitter> <zatherz> .read_line in a loop results in a `End of file reached (IO::EOFError)`
<FromGitter> <drosehn> There's `ripgrep` project written in rust, and the command-name is `rg`.
<FromGitter> <zatherz> doing .rewind after every .read_line results in a `Unable to seek: Illegal seek (Errno)`
<RX14> @zatherz what do you mean pipes
<FromGitter> <zatherz> (yes, rewinding a pipe doesn't make sense, still wanted to say that I tried it)
<FromGitter> <zatherz> RX14: FIFO
<RX14> for what
<FromGitter> <zatherz> what?
<RX14> @drosehn yeah thats what I was referring to
<RX14> what do you need it for
<RX14> "FIFO"
<FromGitter> <zatherz> why does that matter?
<FromGitter> <zatherz> it's a FIFO file
<FromGitter> <zatherz> AKA a named pipe
<RX14> yes
<RX14> but why do you need to rewind it
<FromGitter> <zatherz> I don't need to rewind it
<FromGitter> <zatherz> I want to read from it
<FromGitter> <zatherz> in a loop
<RX14> you know, actually allowing me some background would allow me to help you but whatever
<RX14> so why did you say about rewind
<RX14> and whats the problem
<RX14> what have you tried and what doesn't work
<RX14> "is there a proper way to handle pipes in crystal" yes, they're file desciptors they work like any other IO
<RX14> `#read_line` => Same as #gets, but raises EOFError if called at the end of this IO.
<RX14> from the docs
<RX14> while line = io.gets
<FromGitter> <drosehn> I think he's saying that he needs to know when one process needs to wait for new data before trying to read that new data.
<RX14> that's the typical way to read a file, or use each_line
<RX14> each_line is probably better
<RX14> @drosehn I think zatherz is just trying to read an IO line-by-line
<FromGitter> <zatherz> I think you're misunderstanding how named pipes work
<FromGitter> <zatherz> .each_line and .gets terminate after getting input
<RX14> each_line will return at EOF, yes
<FromGitter> <drosehn> I'm pretty sure that if I was more awake, I could add a comment here which might be helpful. But I'm not more awake... :smile:
<FromGitter> <zatherz> okay, the issue is not in how I read the fifo, but in how I write to the fifo; the fifo receives an EOF from the input when it shouldn't
<FromGitter> <drosehn> Let me make this guess: You have a writing process, and a reading process. And the reader will process data faster than the writer produces new data. So you want your reading-process to ask "is there more data yet?", before it does the next read.
<FromGitter> <zatherz> reading a pipe will not yield an EOF until EOF is written into the pipe
<RX14> @zatherz EOF happens when you call io.close
<Papierkorb> huh is there no #popen yet?
<RX14> popen?
<RX14> isn't that a process thing
<Papierkorb> yes
<RX14> whats wrong with the current
<RX14> ruby's popen and popen3 mess we got rid of
<Papierkorb> erm you can't get "rid off popen"
<RX14> and made a useful interface which does everything
<RX14> what do you mean
<Papierkorb> How do I use then to continually feed data into the process?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Papierkorb> And continually get data out of it
<RX14> we did get rid of popen so yeah, we did remove it
<RX14> you set input: in_io, output: out_io
<RX14> use an IO.pipe to create IO pipes
<RX14> and read/write from other fibers
<Papierkorb> I tried with IO::Memory, upon printing data into it nothing happened
<RX14> well IO::Memory doesn't block because it's not a pipe#
<RX14> it's just a IO which reads/writes to a piece of memory
<Papierkorb> That's not half as good as IO.popen
<Papierkorb> Now we have to teach that people have to mess with pipes manually
<RX14> oh
<RX14> you can use with a block
<RX14> and use the process.input/process.output
<RX14> because they're pipes by default
<RX14> there was a lot of discussion about
<RX14> i think they've ended up with a really nice API
<Papierkorb> Then the docs need an update w.r.t to that
<RX14> how so?
<RX14> the docs are a little barebones but they work
<Papierkorb> It's not obvious how it's intended to work
<Papierkorb> So it does not
<Papierkorb> I was not
<RX14> it does need some examples though
<Papierkorb> I was looking for popen, as that is the actual system call one knows from any other language
<Papierkorb> Doesn't matter it's named differently, for all intents and purposes, it's what people are looking for if they need that
<RX14> why name things after syscalls?
<RX14> it's obscure
<Papierkorb> I didn't say to name it after it
<Papierkorb> I did say to mention it in the docs
<RX14> i mean after you click on process there aren't many things to look through...
<Papierkorb> What?
<Papierkorb> Process is huge
<RX14> it's not too long that you can't scan the class methods
<RX14> and find run
<Papierkorb> I think I made it clear that I was looking for popen, as is the name for this kind of thing everywhere else
<RX14> "everywhere else" being ruby
<RX14> and C