ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
LastWhisper____ has joined #crystal-lang
zipR4ND has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rocky has quit [Remote host closed the connection]
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
hako has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
Redrield has joined #crystal-lang
<Redrield> Hey
<Redrield> Are there any recommended editors/IDEs for working with Crystal
<Redrield> Also, do there happen to be any benchmarks comparing Crystal and Rust?
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
<Redrield> I see there's a VSCode plugin
<Redrield> That any good/
<Redrield> ?
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Redrield has left #crystal-lang ["Leaving"]
<FromGitter> <drosehn> For some of my crystal programs I use Xcode on macOS, but that's just because I use that for working on many other types of files. I also use SublimeText3 for some crystal projects.
<FromGitter> <fridgerator> @Redrield http://awesome-crystal.com/#tools-editor-plugins
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
rohitpaulk has quit [Read error: Connection reset by peer]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sz0 has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #crystal-lang
hako has joined #crystal-lang
hako has quit [Ping timeout: 246 seconds]
LastWhisper____ has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
<FromGitter> <elorest> What is the best way to handle versioning in crystal projects? ⏎ It seems like you have to update version in a least 3 places: ⏎ ⏎ 1) src/yourproject/version.cr ⏎ 2) shard.yml ... [https://gitter.im/crystal-lang/crystal?at=592bac050ba4d59763ee3b3d]
bmcginty has joined #crystal-lang
<FromGitter> <elorest> I just built this to simplify the process if something else doesn’t already exist. https://github.com/elorest/crelease
Kug3lis_off is now known as Kug3lis
mark_66 has joined #crystal-lang
<FromGitter> <greentornado> when will the new version be released ?
<FromGitter> <greentornado> :D
zipR4ND has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
sz0 has joined #crystal-lang
<FromGitter> <sdogruyol> hey everyone
<FromGitter> <greentornado> hi
<FromGitter> <bew> hi :)
<FromGitter> <sdogruyol> how are you doing fellow Crystallers P
<FromGitter> <bew> great! and you?
<FromGitter> <sdogruyol> great
<FromGitter> <sdogruyol> writing some rails to pay the bills :D
<FromGitter> <bew> nice, I work with python currently, I'd love to work with crystal... one day...
<FromGitter> <sdogruyol> hehe same
<FromGitter> <sdogruyol> let's make that happen
<FromGitter> <sdogruyol> what are you doing with python?
<FromGitter> <bew> a learning plateform for bigdata stuff (R, python)
<FromGitter> <sdogruyol> wow cool
<FromGitter> <bew> using AWS ( <--- they are awesome! )
<FromGitter> <aolko> > lateform ⏎ ⏎ mmm...tasty bigdata
<FromGitter> <sdogruyol> :D
zipR4ND has quit [Ping timeout: 245 seconds]
<FromGitter> <bararchy> Will it be faster to do `Bytes == Bytes`, or `String == String` from CPU point of view ?
<FromGitter> <bararchy> as in, I got a ID i'm passing around and checking between a few methods, ID is passed via a socket so it's a `Slice`, should I `String.new`on it ? or just compare it as slice ?
<FromGitter> <bararchy> it should not be relevant for users, etc..
<FromGitter> <bew> it'll be a little faster using Bytes, but it's a matter of one more comparaison for strings
splitty__ has joined #crystal-lang
<FromGitter> <bararchy> What do you mean by one more comparaison ?
<FromGitter> <bew> The String `==` implementation have a comparaison to check if you're comparing the string to itself (same object_id), else, it's the same as `Slice`
<FromGitter> <bararchy> Oh
<FromGitter> <bararchy> as in, it will get `.to_slice` for the test ?
<FromGitter> <bew> no, but the implementation is the same
<FromGitter> <bew> (it doesn't create a interediate Slice object)
<FromGitter> <sdogruyol> Yeah
<FromGitter> <bararchy> Hm... seems there is quite a differnce though : https://play.crystal-lang.org/#/r/23oa
<FromGitter> <sdogruyol> Crystal's String implementation is just great and performant
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> It seems that non string comparison is much much faster ⏎ ⏎ ```Non string: 00:00:00.3933856 ⏎ String: 00:00:05.6660935``` [https://gitter.im/crystal-lang/crystal?at=592c0a5200efc2bb3eb60208]
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> Or is it because I String.new in the test
splitty___ has quit [Ping timeout: 268 seconds]
<FromGitter> <bararchy> hm..
<FromGitter> <bararchy> just thought about it now XD
<FromGitter> <bew> here without string creation inside the loop
<FromGitter> <bararchy> Yeha, it looks almost the same speed
<FromGitter> <bararchy> Thanks guys :)
<FromGitter> <bew> yw :)
zipR4ND has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
zipR4ND has quit [Ping timeout: 245 seconds]
<FromGitter> <bew> Is there a way to get the current stack usage ?
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> GC.stats ?
<FromGitter> <bew> this is for heap memory, not stack
<FromGitter> <sdogruyol> oh sorry
<FromGitter> <bew> I'm not sure it's even possible :/
<FromGitter> <sdogruyol> well a stack is a stack for a reason :D
snsei has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
<FromGitter> <abidon> hi guys, is someone able to help me on an issue i'm having ? 😊
<FromGitter> <sdogruyol> hey
<FromGitter> <bew> it depends on the issue
<FromGitter> <abidon> haha ok i'll take the risk 😜
<FromGitter> <abidon> i’m new to crystal and i’d like to know about some stuff in the language to face an issue i’m having. can method resolution be dynamic ? in fact, i’m using crystal to both develop a core application and plugins (which take form of dynamic libraries, nothing fancy here), but when i pass an instance of a concrete class from a plugin to the core app, it then fails when calling its methods saying:
<FromGitter> ... `’service.bootstrap(self)’ has no type (Exception)`
<FromGitter> <bew> methods resolutions cannot be dynamic
<FromGitter> <sdogruyol> that's a good question
<FromGitter> <bew> I managed to get working a crystal shared library as plugin for a C core program, but never tried yet with a crystal core program
<FromGitter> <bew> can you share a little code example (in a repo for example), to see more what you're doing?
<FromGitter> <bew> the error is at runtime or at compile time?
<FromGitter> <abidon> yes of course, just give me a bunch of minutes to create a simplified version of the "thing"
<FromGitter> <abidon> runtime error
<FromGitter> <abidon> in fact, i have 3 things, a "lib" shard with an abstract class "Service", a plugin which is compiled using the `-shared` linker flag and implements a concrete Service, and the core which dlopen the plugin and call a method on it to ask the plugin for the services it exposes. Then, the core try to call the `bootstrap` method on the concrete Service instance (which is a method defined as abstract in the lib shard)
<FromGitter> ... and it crashes with the error message above
<FromGitter> <abidon> i'm doing a repo with everything needed to reproduce the issue
snsei has joined #crystal-lang
<FromGitter> <bew> I'm very interested for a plugin system like this, with crystal only :)
<FromGitter> <abidon> so do i ! 😂
<FromGitter> <straight-shoota> Is there an easy solution for re-raising an exception with keeping the same callstack? I want to add some additional info to an exception wich is not available where the exception is created.
<FromGitter> <bew> your workflow (as you described it) should work.. (@abidon)
<Yxhuvud> method resolution cannot be dynamic, but there are union types, where a value can be one of a predefined set of types, and method call resolution do work on those sets.
<FromGitter> <straight-shoota> Reimplementing `::raise` seems like a bad idea...https://github.com/crystal-lang/crystal/blob/64e7b426d5793bcb44f3ffc65b7f31e66f486150/src/raise.cr#L178 ⏎ Guess I could create a wrapper exception with the original exception as cause and unwrap at the exception handler... maybe it can be done simpler?
<FromGitter> <abidon> @yxhuvud but isn't it possible because its done at compile time ?
<Yxhuvud> abidon: sure. But it still allows some freedom
<FromGitter> <bew> @straight-shoota was looking at how `raise` is implemented, it doesn't seems possible to do what you want currently..
<FromGitter> <bew> @abidon this is the `core` who is crashing?
<FromGitter> <akzhan> it’s easy to extend `raise` method but need a reason.
<FromGitter> <abidon> @bew yup
<FromGitter> <bew> I think you entered this case during core compilation: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/semantic/cleanup_transformer.cr#L254
<FromGitter> <akzhan> may be ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=592c41a8631b8e4e612434f9]
<FromGitter> <abidon> @bew that's what i was thinking too, just wanted to be sure
<FromGitter> <bew> oh @akzhan looks nice
<FromGitter> <bew> @abidon I don't think you can use OO between the core and the plugin (because of this, and also because of the function names mangling too..), you'll need a C-like interface, with simple functions accepting a Service, but even that, I'm not sure it'll correctly work
<FromGitter> <straight-shoota> @akzhan That won't work because `new_e.callstack` will be overwritten by `raise`
<FromGitter> <bew> @straight-shoota it may work if you call __crystal_raise yourself.. but that's another story
<FromGitter> <straight-shoota> Yes, I wouldn't want to touch that directly
<FromGitter> <akzhan> hm, raise.cr may be updated to set callstack only id needed.
<FromGitter> <straight-shoota> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=592c432a2b926f8a67a3d677]
<FromGitter> <akzhan> but there is another idea - take in care `cause` property.
<FromGitter> <straight-shoota> This wrapper solves it for now, but a direct way would be nice
<FromGitter> <abidon> @bew isn't some vtable-like system feasible or planned ?
faulty has joined #crystal-lang
faulty has quit [Client Quit]
<FromGitter> <akzhan> @straight-shoota May pull request with ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ ? [https://gitter.im/crystal-lang/crystal?at=592c4493cb83ba6a410dffd4]
<FromGitter> <akzhan> it should not change bahaviuor of stdlib because `cause` not used anywhere in sodlib.
<oprypin> abidon, a conventional vtable is not needed, there is a more flexible alternative already in place
<FromGitter> <bew> @abidon Not planned, currently the methods are copy/pasted for each types, there is no vtable system... Might be feasible, using low-level hacking, but I'm not sure it's a good idea to mess with that
<oprypin> a type can always be determined at runtime and hence all the methods that concern it
<FromGitter> <bew> I pass, the expert is there :)
<oprypin> the compiler must know at compile time not only names of methods but also types of all arguments and generate the according machine code for that particular instantiation of the method
<oprypin> so fully dynamic dispatch is impossible. but a dynamic dispatch already exists
<oprypin> just do if obj.responds_to? :stuff; obj.stuff("asdf"); end
<oprypin> should work i think
<FromGitter> <bew> oprypin, but the `obj.stuff("bla")` will still raise in this case
<oprypin> it cannot "raise", it might fail at compile time
<Yxhuvud> bew: Yes, unless all members of the union type respond to stuff.
<oprypin> it will not fail at compile time unless ANY of the members of the union type respond to stuff
<FromGitter> <bew> It can raises at run time when the object is abstract: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/semantic/cleanup_transformer.cr#L254
<oprypin> uhh too many negations, i messed up
<FromGitter> <straight-shoota> @akzhan With causes you might also want to keep both callstacks of the inner and outer exception. So I don't think it should take the callstack from the cause by default.
<oprypin> bew, well a object literally can't exist if it's abstract, but yeah, there are some convoluted ways to trick the compiler into that
<FromGitter> <bew> @straight-shoota you could put the first callstack into the second exception as the message ?
<oprypin> or the runtime, rather
<FromGitter> <straight-shoota> Why not? ⏎ ⏎ ```ex.callstack ||= Callstack.new``` [https://gitter.im/crystal-lang/crystal?at=592c46160a783b6c0ae76252]
<FromGitter> <straight-shoota> Just don't overwrite the callstack if there already is one.
<FromGitter> <abidon> @oprypin the fact is that the object isn't abstract, its a concrete instance from a dynamically loaded library.
<FromGitter> <bew> @abidon but from the `core` point of view, what is it?
<FromGitter> <abidon> @oprypin but the core program thinks its abstract, because the concrete type is not known at compile time from the core point of view
<oprypin> abidon, could you do (Subclass1|Subclass2|Subclass3) instead of using the abstract base?
<oprypin> it still should work even with abstract though
<oprypin> do you have an example?
<FromGitter> <bew> @abidon is this the kind of error you have ? https://carc.in/#/r/23py
<oprypin> and you're mentioning a dynamic library, that's probably not gonna work at all. a dynamic library must have only concrete types
<FromGitter> <abidon> @oprypin not really, as i would would loose all the modularity of loading concrete instances that are of unknown type for the "core"
<FromGitter> <abidon> @oprypin I'm doing an example repo, just give me some time
<oprypin> Crystal classes cannot be exposed in a dynamic library
<FromGitter> <abidon> that's why i feel constrained to switch to another programming language, sadly...
<FromGitter> <bew> @abidon is this the error you get ? https://carc.in/#/r/23py
<FromGitter> <abidon> thats the same error yes
<FromGitter> <abidon> while i'm not using pointers
<FromGitter> <bew> yes, but this is the shortest way to trick the compiler
<FromGitter> <bew> well you have the concrete class instance which is a pointer, no?
<FromGitter> <abidon> no, its passed by reference
<FromGitter> <abidon> let me do the example repo and we'll all be able to hack around the thing haha :smile:
<FromGitter> <bew> Perfect :+1:
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
snsei has quit [Ping timeout: 272 seconds]
<FromGitter> <akzhan> @straight-shoota It works: ⏎ ⏎ https://gist.github.com/akzhan/13771b16dd12c01496a42a7153bcf72a ⏎ ⏎ Anyway we need to know.. may be optional parameter callstack_from_cause = false [https://gitter.im/crystal-lang/crystal?at=592c4ce2f3001cd3426d9c5d]
<FromGitter> <akzhan> or make generic raise_clause, and more specific raise on top.
<FromGitter> <straight-shoota> great :+1:
<FromGitter> <straight-shoota> I'm already typing an issue
<FromGitter> <abidon> @bew / @oprypin : here it is, a reproduction of the bug https://github.com/abidon/crystal_method_resolution_fail
<FromGitter> <abidon> please tell me there is a way to make that happen !
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <straight-shoota> @akzhan I actually can't understand your second spec.. Why is the message of SomeError the backtrace of `ex`?
<FromGitter> <akzhan> SomeError constructor got cause - inner exception.
<FromGitter> <bew> @abidon will try in a few hours, no time now :/
<FromGitter> <straight-shoota> Ah okay, `expect_raises` checks if the string is somwhere in the error message
LastWhisper____ has joined #crystal-lang
<FromGitter> <akzhan> it’s short spec for callstack equality without creating of specific helper that tests for callstack itself.
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Kug3lis_off is now known as Kug3lis
pta2002 has joined #crystal-lang
<pta2002> hi, this is probably a bad idea but... is there any way to make kernel calls?
<pta2002> e.g. fork
<FromGitter> <bew> pta2002, `Process.fork` will handle everything for you :)
<pta2002> FromGitter: cool
<FromGitter> pta2002, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<pta2002> oops
<pta2002> bew: that was for you
<pta2002> bew: does it work like c fork?
<FromGitter> <bew> Almost, see the documentation
<pta2002> i have 2 other syscalls i want to use though
<pta2002> (dep2 and execvp)
<pta2002> ((yes i'm trying to make some kind of shell))
<FromGitter> <bew> https://crystal-lang.org/api/0.22.0/Process.html#fork%28%26block%29-class-method
<FromGitter> <bew> In this page you also have the documentation for `Process.exec`. I you just want to fork & run, you should go with `Process.run`
<pta2002> bew: how do i check the pid?
<FromGitter> <bew> Look at the link I gave above
<pta2002> oh
<pta2002> child returns nil, parent returns process
<FromGitter> <bew> That's it!
<FromGitter> <bew> If you really need to pid, you can use `Process#pid` to access id from a `Process` instance
<pta2002> yep there we go
<FromGitter> <bew> s/id/pid
<pta2002> thanks :)
<pta2002> how do i do dep2 aka i/o redirect?
<pta2002> s/dep2/dup2
<FromGitter> <bew> IO redirect is easy with IO.pipe iirc
<FromGitter> <bew> But I don't remember how
<pta2002> hm okay
<pta2002> bew: that just creates a pipe, doesn't redirect io to it
<FromGitter> <bew> Yeah I know, what kind of redirect do you need?
<FromGitter> <bew> Files? Shell piping?
<pta2002> i mean they work basically the same way
<pta2002> at least in c, both files and pipes return a file descriptor
<pta2002> and you just redirect to it
<pta2002> so redirection is basically the same
<pta2002> but yeah i want to redirect to a pipe
<FromGitter> <bew> Maybe you can simply use `Process.exec`? See the list of arguments
<pta2002> hm
<pta2002> ah yep
<pta2002> thanks :)
<pta2002> bew: can I do waitpid
<FromGitter> <faultyserver> https://crystal-lang.org/api/0.22.0/Process.html#wait%3AProcess%3A%3AStatus-instance-method
<pta2002> faultyserver: is that the same as waitpid though
<pta2002> from what i see that just hangs until it closes
<pta2002> that's not what i want
<pta2002> i want to do a thing while it doesnt close
<pta2002> ah, terminated?
<FromGitter> <faultyserver> Probably. Are you just wanting to wait for all of your Processes to finish before your program quits?
LastWhisper____ has joined #crystal-lang
<FromGitter> <faultyserver> If so, then yeah, just track them and check for `processes.all(&.terminated?)` at the end
<pta2002> nah
<pta2002> i'm trying to do some stuff on the program's output if that makes any sense
<FromGitter> <faultyserver> I don't really follow
<FromGitter> <faultyserver> you're trying to capture the output and keep capturing until the process finishes?
<FromGitter> <faultyserver> You could also ask `process.output.closed?` in that situation
<FromGitter> <bew> You can use `child_process.output` to read program output directly
TheLemonMan has joined #crystal-lang
<pta2002> hmm
<pta2002> it will only output if it errors
A124 has quit [Quit: '']
A124 has joined #crystal-lang
<FromGitter> <faultyserver> You don't need the `IO.pipe`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=592c672e631b8e4e6124d193]
<FromGitter> <pta2002> oh cool
<FromGitter> <pta2002> (gonna use gitter for now)
pta2002 has quit [Quit: WeeChat 1.7.1]
<FromGitter> <pta2002> @faultyserver what if I want to write to stdin?
TheLemonMan has left #crystal-lang [#crystal-lang]
<FromGitter> <faultyserver> on the child?
<FromGitter> <pta2002> well, redirect something to the child's stdin
<FromGitter> <pta2002> don't i need a pipe for that
<FromGitter> <pta2002> set on inpur
<FromGitter> <faultyserver> you can set `input` on `Process.exec` to any file descriptor
<FromGitter> <pta2002> okay
<FromGitter> <pta2002> why doesn't the output work though, on my example
<FromGitter> <pta2002> that's weird, no?
<FromGitter> <faultyserver> Worked for me: ```The program wrote require "./import.cr" ⏎ The program wrote ⏎ The program wrote import "./other2.cr", Library```
<FromGitter> <faultyserver> (reading a different file)
<FromGitter> <pta2002> hmm
<FromGitter> <faultyserver> are you sure `/etc/hostname` isn't blank?
<FromGitter> <faultyserver> or maybe it doesn't end with a newline? idk if that would affect it, though
<FromGitter> <pta2002> it does not end with \n
<FromGitter> <pta2002> maybe that's it
<FromGitter> <faultyserver> That almost seems like a bug in `gets`, imo
<FromGitter> <faultyserver> I feel like it should detect EOF and treat that as a newline
<FromGitter> <pta2002> seems like it
<FromGitter> <pta2002> it works with multiple lines
<FromGitter> <pta2002> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=592c691ceec422e415fe0c25]
<FromGitter> <faultyserver> oh, it does hang for me, too :/
<FromGitter> <faultyserver> I just ctrl+c'd without thinking
<FromGitter> <faultyserver> yeah, I'd say that's a bug with `gets`
<FromGitter> <pta2002> well i'll open an issue
<FromGitter> <pta2002> wait it worked above
<FromGitter> <pta2002> shouldn't hang though...
<FromGitter> <faultyserver> yeah, the hang is the issue, imo
<FromGitter> <faultyserver> `gets` isn't detecting EOF or something, so it just hangs
<FromGitter> <bew> No bug here : https://carc.in/#/r/23qy
<FromGitter> <pta2002> ```code paste, see link``` ⏎ ⏎ this hangs too [https://gitter.im/crystal-lang/crystal?at=592c69f1fa63ba2f76905ecd]
<FromGitter> <pta2002> seems like the problem's with process.terminated
<FromGitter> <pta2002> replacing the Process.exec with Process.exit hangs too
<FromGitter> <bew> I think because you never did `child.wait`
<FromGitter> <bew> This is needed to terminate the process
<FromGitter> <pta2002> ah so that's what i wanted
<FromGitter> <pta2002> where do I put wait
<FromGitter> <pta2002> yay it works
<oprypin> abidon, getting `plugin: version node not found for symbol *Pointer(Array(Debug::DWARF::LineNumbers::Row))@Pointer(T)#realloc<Int32>:Pointer(Array(Debug::DWARF::LineNumbers::Row))`
<FromGitter> <pta2002> how do I test if there's any change in a file descriptor thing
<oprypin> i dont get it
<FromGitter> <bew> oprypin, same, I think it's shared library compilation is broken, or somthing like that
<FromGitter> <abidon> it works on macos, i haven't tested on linux yet, but looks weird...
<FromGitter> <abidon> maybe compiling in release would bypass debug information generation ?
<FromGitter> <bew> compiling with `--release` works
<FromGitter> <abidon> @bew nice
<FromGitter> <bew> now I get `plugin: cannot open shared object file: No such file or directory (Exception)`...
<FromGitter> <abidon> @bew ...
<FromGitter> <bew> ok it works when using `Dyn.new "./plugin"`
<FromGitter> <bew> I get you error
<FromGitter> <abidon> haha ok updating the repo
ryanf has quit [Quit: leaving]
ryanf has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <pta2002> hm
<FromGitter> <pta2002> how do I know if there's anything left to read?
<FromGitter> <pta2002> from an IO
<FromGitter> <faultyserver> https://crystal-lang.org/api/0.22.0/IO.html#gets%28limit%3AInt%2Cchomp%3Dfalse%29%3AString%3F-instance-method ⏎ ⏎ `gets` returns `nil` if called at the end of an IO
<FromGitter> <faultyserver> i.e., when there's nothing left to read
<FromGitter> <abidon> @pta2002 there's also `gets_to_end` (https://crystal-lang.org/api/0.22.0/IO.html#gets_to_end%3AString-instance-method)
<FromGitter> <pta2002> @abidon it's a pipe though
<FromGitter> <abidon> @pta2002 (sorry, didn't took the discussion from the beggining)
<FromGitter> <bew> if the pipe isn't closed, it'll block iirc
<FromGitter> <faultyserver> yeah, you can't trust that you're at the end of the output if the pipe isn't closed
<FromGitter> <pta2002> so how do i know to close it?
<FromGitter> <faultyserver> `output.closed?`
<FromGitter> <faultyserver> it's the sender's responsibility to close the pipe when they're done
<FromGitter> <faultyserver> i.e., if you're reading from a child process, the child is responsible for closing it's write end of the pipe
<FromGitter> <pta2002> ```code paste, see link``` ⏎ ⏎ this isn't working [https://gitter.im/crystal-lang/crystal?at=592c73202b926f8a67a4a040]
<FromGitter> <faultyserver> I'd really suggest going with the pipeless version I posted earlier
<FromGitter> <bew> (your `while !child.terminated?` is useless, it will never reloop
<FromGitter> <faultyserver> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=592c734f631b8e4e6124fec7]
<FromGitter> <pta2002> @faultyserver yeah, I'll use that, but now I'm determined to finish it :P
<FromGitter> <pta2002> @bew but not every program outputs all at once
<FromGitter> <pta2002> so it could happen that it would, right?
<FromGitter> <bew> it'll loop in the inner while, not the outer while
<FromGitter> <pta2002> oh okay
<FromGitter> <pta2002> still not working
<FromGitter> <bew> first, `read` will never close by itself
<FromGitter> <bew> @pta2002 found it!
<FromGitter> <bew> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=592c761000efc2bb3eb7e73f]
<FromGitter> <bew> you need to close the pipe's ends you don't need in the parent, and in the child
<FromGitter> <bew> > The system will assume that a write could occur while any process has the write end open, even if the only such process is the one that is currently trying to read from the pipe, and the system will not report EOF, therefore.
<FromGitter> <bew> and
<FromGitter> <bew> > Even if the parent has completed writing, your while loop below this line will block for ever for the read to return 0(ie EOF). This happens since even if the parent has completed writing and closed the write end of the pipe, the reference count of the write end in the File table is still 1 (Initially it was 2) and so the read function still is waiting for some data to arrive which will never happen.
<FromGitter> <bew> (they explain what it does when not closing the pipe end)
<FromGitter> <pta2002> ahh, thanks a lot! :)
<FromGitter> <pta2002> now I can fulfill my extremely stupid goal of making a web terminal
<FromGitter> <bew> I have no idea :D
<FromGitter> <bew> nice project
<FromGitter> <pta2002> heh
<FromGitter> <pta2002> i made a shell in python so I thought I'd do a terminal emulator
<FromGitter> <pta2002> but UI libraries are a PITA
<FromGitter> <pta2002> so html is nice
<FromGitter> <faultyserver> if you're doing it in HTML, make sure to use the `ch` length unit (https://developer.mozilla.org/en-US/docs/Web/CSS/length#ch) for sizing :)
<FromGitter> <pta2002> huh
<FromGitter> <pta2002> why 0 in particular?
<FromGitter> <faultyserver> kinda arbitrary
<FromGitter> <pta2002> hm
<FromGitter> <faultyserver> but also consistent. Most psuedo-monospace fonts have 0 as the max-width character
<FromGitter> <pta2002> I guess that when you're using this you'd be doing monospace, so it wouldn't really matter
<FromGitter> <faultyserver> at least they did at one point
<FromGitter> <faultyserver> yeah, it's just a nice guarantee of e.g. 80-character width
<FromGitter> <faultyserver> Just don't use Roboto (https://github.com/google/fonts/issues/251)
zipR4ND has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
pta2002 has joined #crystal-lang
<FromGitter> <pta2002> hm
A124 has quit [Ping timeout: 255 seconds]
<FromGitter> <pta2002> god dammit "smart" shells
rohitpaulk has joined #crystal-lang
<FromGitter> <pta2002> how do I make them think my stdin is interactive
<FromGitter> <bew> you need to make it a terminal
<FromGitter> <pta2002> how
<FromGitter> <bew> the way they detect this is through `isatty`
<Papierkorb> pta2002, create PTY
<FromGitter> <bew> you should look at pseudo tty
<FromGitter> <pta2002> oh
<FromGitter> <pta2002> hmm
<travis-ci> crystal-lang/crystal#3961dd0 (master - Compiler: correct to handle instance variable assignment inside block on global (#4324)): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/236412925
<DeBot> https://github.com/crystal-lang/crystal/pull/4324 (Compiler: correct to handle instance variable assignment inside block on global)
Philpax has quit [Read error: Connection reset by peer]
Philpax has joined #crystal-lang
<FromGitter> <bew> Is there a way to write: `def initialize(external_name @internal_name)` ?
<Papierkorb> If that doesn't work I don't have a better answer bew
<FromGitter> <bew> nvm, I messed up sth else, it works
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <bew> thanks :)
<FromGitter> <bew> I think this is a bug: https://carc.in/#/r/23s0 IMO it should say that it doesn't know `UnknownType`, no?
LastWhisper____ has joined #crystal-lang
VectorGraphics has joined #crystal-lang
chatter29 has joined #crystal-lang
<chatter29> hey guys
<chatter29> allah is doing
<chatter29> sun is not doing allah is doing
<chatter29> to accept Islam say that i bear witness that there is no deity worthy of worship except Allah and Muhammad peace be upon him is his slave and messenger
<chatter29> As-salāmu ʿalaykum (Arabic: السَّلَامُ عَلَيْكُمْ‎‎ [asːaˈlaːmu ʕaˈlaikum]) is a greeting in Arabic that means "peace be upon you". The greeting is a standard salutation among Muslims and is routinely used whenever and wherever Muslims gather and interact, whether socially or within worship and other contexts. [1] The typical response to the greeti
<chatter29> ng is waʿalaykumu s-salām (وَعَلَيْكُم السَّلَام [waʕaˈlaikumu sːaˈlaːm]; "and upon you, peace").
<chatter29> prophet muhammad peace be upon him was sent to destroy the musical instruments
<chatter29> men must have one fist beard
zipR4ND has quit [Read error: Connection reset by peer]
chatter29 has quit [Client Quit]
<VectorGraphics> A fist beard? That's pretty manly
<pta2002> the fuck
zipR4ND has joined #crystal-lang
<VectorGraphics> Does anyone happen to know if there is a way to either list/iterate over all instance variables or if they can be selected by name? I have several properties and want to do something simple like only print the names and values of ones that aren't nil
<FromGitter> <bew> this can be done with macros
<FromGitter> <bew> see `Object#to_s`
pta2002 has quit [Quit: WeeChat 1.7.1]
<VectorGraphics> Thanks, bew. I might just unroll what I'm trying to do
<RX14> next time just ping me about the islambots and i'll ban them
<FromGitter> <bew> roger that
<TheGillies> it's always the same nick
<TheGillies> which amazes me
<TheGillies> like why don't we just ban the nick
<RX14> oh wow it is
<RX14> i assumed it wasn't
<RX14> well then problem solved
<FromGitter> <bew> oprypin I don't know if you finally tried to make it work (shard library as plugin), but I did and it works pretty well ;)
<TheGillies> I love that as part of his proselytism he copy/pastes wikipedia. so devout in his conviction heh
<RX14> i think thats how it works lol
<RX14> yup
<RX14> hopefully that solves the problem but I doubt it - they'll notice and choose a different username
Kug3lis is now known as Kug3lis_off
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<oprypin> sorry i was away
<oprypin> and still will be away
<FromGitter> <bew> np