<FromGitter>
<exts> anyone got a recommended shard to get file info (metadata)
<FromGitter>
<bew> weird, I have a code using `out some_var` that fails (the lib I'm binding to make an error), and when I use `uninitialized` then `pointerof` it works. I though it was the same as using `out`
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eliasjpr has joined #crystal-lang
eliasjpr has quit [Ping timeout: 240 seconds]
<FromGitter>
<Twister915> Hey, I'm having a lot of trouble compiling something I've been writing. It's pretty generics heavy. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ and I only know that the problem is with this generic because if I comment out `one_completed` it compiles [https://gitter.im/crystal-lang/crystal?at=59fe5d8d2a69af844b4c1d13]
<FromGitter>
<Twister915> I can provide all of the relevant code if requested, just didn't want to make it too huge an issue to understand.
<FromGitter>
<bew> can you provide the full error first?
<FromGitter>
<Twister915> the third and largest block of text is the entire output of the command `crystal run array.cr `
<vivus>
how do I get around an error like this: in config/routes.cr:2: can't declare def dynamically ... def web_pipeline ... ?
<FromGitter>
<Twister915> well what's weirder is commenting out an unmentioned method will fix the error
<FromGitter>
<picatz> I'm seem to have an error when calling the first interface name. Sometimes it's an empty string; and other time it's junk like `???` or `_d??` for some odd reason.
<FromGitter>
<bew> @picatz going to sleep now, sry!
<FromGitter>
<picatz> No worries!
<FromGitter>
<bew> I think you should write a wrapper around PcapIf, that creates a crystal String (with `String.new(raw_iface.name)`)
<FromGitter>
<bew> ++
faustinoaq has quit [Ping timeout: 240 seconds]
eliasjpr has joined #crystal-lang
faustinoaq has joined #crystal-lang
eliasjpr has quit [Ping timeout: 240 seconds]
Guest74140 is now known as Cyrus
Cyrus has quit [Changing host]
Cyrus has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter>
<exts> man I love crystal. such a pleasant to write
<FromGitter>
<crisward> @exts 👍
eliasjpr has joined #crystal-lang
qard has joined #crystal-lang
eliasjpr has quit [Ping timeout: 248 seconds]
<FromGitter>
<exts> 'can't use Hash(K, V) in unions yet, use a more specific type' :'(
illyohs has quit [Read error: Connection reset by peer]
eliasjpr_ has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
eliasjpr_ has quit [Ping timeout: 240 seconds]
shankar has joined #crystal-lang
shankar_ has joined #crystal-lang
shankar has quit [Ping timeout: 260 seconds]
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
shankar_ has quit [Remote host closed the connection]
Kug3lis is now known as Kug3lis_off
shankar has joined #crystal-lang
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
shankar_ has joined #crystal-lang
shankar has quit [Ping timeout: 240 seconds]
shankar_ has quit [Ping timeout: 260 seconds]
eliasjpr_ has joined #crystal-lang
faustinoaq has quit [Ping timeout: 240 seconds]
eliasjpr_ has quit [Ping timeout: 240 seconds]
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
Kug3lis_off has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has joined #crystal-lang
_whitelogger has joined #crystal-lang
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 248 seconds]
lacour has quit [Quit: Leaving]
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 248 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 252 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Groogy has quit [Read error: Connection reset by peer]
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<unreadable> Morning!
Groogy has joined #crystal-lang
<Groogy>
Morning!
<FromGitter>
<bararchy> I have two sentences, I want to calculate what percente of the sentences is alike ⏎ I thought about doing `.chars` on both sentences, then try and see how many "wrong" chars are there and calculate it against the string length or something, but I can't figure out exactly how
<FromGitter>
<bararchy> any ideas ? :)
<FromGitter>
<bararchy> Morning guys !
<Groogy>
how you said it is pretty much how to?
<Groogy>
wrong_chars / str.length => percentage
<Groogy>
you could also do str.count { |char| wrong_chars += 1 if is_wrong }
<Groogy>
or wait no I am dumb that's not how it works
<Groogy>
though can probably make it more "crystal-esque" somehow
<FromGitter>
<bararchy> The thing is I need the index to know the same placmen for the "second" string
<FromGitter>
<bararchy> else string.count would do just fine
<FromGitter>
<bararchy> I would also lovee select_with_index
<FromGitter>
<bararchy> lol
claudiuinberlin has joined #crystal-lang
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<Qwerp-Derp> wait what highlighting does gitter.im use?
<FromGitter>
<bararchy> Not a really good one :)
<FromGitter>
<bew> I usually use ruby to highlight crystal code in gitter (please don't beat me ^^)
<FromGitter>
<Qwerp-Derp> well i mean if it ain't broke...
<FromGitter>
<bew> @exts use 255.to_s(16) to get the hex!
<FromGitter>
<bew> @Twister915 can you `pp typeof(@target_observer), @target_observer.class` to see what the compiler sees about the types and what it really is?
<FromGitter>
<bew> @bararchy not related to you problem,but why to you keep an array of all the valid chars if you only want the size? You're loosing time & memory with the array imo
<FromGitter>
<bew> looks too clean to work, but still! really nice!
<Groogy>
it does work that's the cool thing :P
<FromGitter>
<bew> awesome ;)
<Groogy>
It's nice being able to split off work like this. WindowHeaderDrag handles the logic for translating Boleite::InputEvent's to eventually a call on header_drag
<Groogy>
so the code becomes extremly minimal and the state code needed for "are we dragging or not" is delegated to WindowHeaderDrag
<Groogy>
and doesn't pollute the Window class
<FromGitter>
<bew> do you have that level of clarity in C++ (in C++ terms) ?
<Groogy>
eh not really, not in my old code at least
<Groogy>
could possibly do it, how my glue code is inspired by a trick we do with templates a lot
<Groogy>
how my old code was just the widgets themselves passing on a event object in a handleEvent method
<Groogy>
anyway gonna head to the office, got some last minute stuff before RC candidate lock I wanna do
<Groogy>
cya
<FromGitter>
<bew> RC?
<Groogy>
release candidate
<Groogy>
oh lol so I said release candidate candidate xD
<FromGitter>
<bew> ah ok! ty
<Groogy>
i.e the version we provide as "what we want to release pending approval from QA"
<Groogy>
anyway I'll be back when I get to that computer
<FromGitter>
<bew> copy that ;)
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 248 seconds]
bazaar has joined #crystal-lang
<Papierkorb>
bew, you have this level of clean with C++/Qt
rohitpaulk has joined #crystal-lang
<FromGitter>
<bew> that's good!
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<exts> @bew nice tip on the decimal to hex
<FromGitter>
<exts> where's the api docs repo? I need to report a bug on an example listed
eliasjpr_ has quit [Ping timeout: 248 seconds]
<FromGitter>
<crisward> @exts the docs are comments in the code in the main repo. If you click the [view source] link it should take you straight to it.
<FromGitter>
<exts> thanks
faustinoaq has joined #crystal-lang
eliasjpr_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 248 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 260 seconds]
eliasjpr_ has joined #crystal-lang
<FromGitter>
<Sevensidedmarble> Is there any equivalent to Ruby's Process.waitall in Crystal?
eliasjpr_ has quit [Ping timeout: 255 seconds]
<FromGitter>
<Sevensidedmarble> I could just loop through things and #wait them all individually but I wish waitall was an option
<Papierkorb>
`processes.each(&.wait)`
<FromGitter>
<Sevensidedmarble> that works too thank you
<faustinoaq>
Interesting, https://github.com/nim-lang/c2nim, Would be good a c2Crystal or maybe Ruby2Crystal ? Of course, with some limitations :)
<Papierkorb>
Most of ruby that uses meta-programming isn't 1:1 portable
<Papierkorb>
And honestly, I don't want people flicking a switch and then have everything-Ruby. If they want "ruby but speed", please use JRuby. A TON of paradigms in Ruby simply don't port over well, or at all, to Crystal. We'd end up with large swaths of simply bad libraries
<Papierkorb>
Which in turn could significantly reflect badly on the public perception of Crystal
<Papierkorb>
> c2nim is preliminary meant to translate C header files. Because of this, the preprocessor is part of the parser. For example:
<Papierkorb>
faustinoaq: So, you mean, bindgen?
<faustinoaq>
Yeah, I agree +1, What about C2Crystal ? Do you think bindgen is a better solution that transpiling source code?
<faustinoaq>
Oh, I see bindgen is very similar approach
<Papierkorb>
faustinoaq: Fully transpiling a C project doesn't really have huge benefits. Not to mention the issues that come with it.
<Papierkorb>
Even our I/O model is different to C, so you may break assumptions the C code does
<Papierkorb>
And C code is basically a chain of assumptions
<Papierkorb>
If the C language allows something arcane which no one does, you can bet that someone will do it
<Papierkorb>
You can e.g. throw off many C binding generators (not specific to Crystal) by doing `typedef void(Foo)(...);`, leaving out the pointer (So writing `Foo *foo` later instead of `Foo foo`)
<Papierkorb>
And that's just one thing that many overlook
<Papierkorb>
Transpiling small macros may be possible, but even here only within reason.
eliasjpr_ has quit [Ping timeout: 240 seconds]
<Papierkorb>
Stuff like `#define OR(x) || (x)` is valid for the C preprocessor, even if it's not a valid AST. Crystals macro system OTOH requires that the output of a macro is a valid AST by itself. A macro like this can't be wrapped.
<Papierkorb>
So building a transpiler to rule them all simply isn't feasible. And things like #ifdef are really better left int the C/C++ parts. While it may look cool when you port those too, what's the benefit? These checks are mostly *highly* specific to the environment they check. Crystal isn't a C environment, so even if you'd "port" those checks, they'd break left and right.
<Papierkorb>
q.e.d
<faustinoaq>
Ok, I see, Crystal is more complex that Nim (for good (^_^;)), Thanks you for your advices :)
<Papierkorb>
Well those #ifdefs transpilings will breaks just a s well in Nim. Except if they'd "emulate" a C environment.
<Papierkorb>
In which moment, please, just use C, there are a ton of good compilers to choose from
<Papierkorb>
and every sane OS comes with a C compiler
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<picatz> 👋 Hello again! I'm having a bit of trouble again understanding the use of a C function bindings and how it's used in Crystal. I've been struggling with it since last night / into this morning and figured I'd ask here. *Essentially*, I'm just trying to figure out to use the `pcap_dispatch` function form libpcap as described here: https://github.com/puppetpies/crystal-libp
<FromGitter>
<bew> the current docs is the language reference, not how to use the language. as RX14 said somewhere we're missing an intermediate tutorial between the lang reference and the API docs
<FromGitter>
<exts> that's not the tutorial? seems like a tutorial
<FromGitter>
<bararchy> @bew Thanks !
<RX14>
the only thing in the language reference is stuff in the compiler
<RX14>
and the only thing in the api ref is stuff in the stdlib
<RX14>
perhaps there's a bit of crossiver
<RX14>
but not_nil!'s absolutely stdlib
<faustinoaq>
Hey, `not_nil!` is a bad practice? I mean moving the error from compile-time to runtime
<Papierkorb>
#not_nil! is to be used when it really should never be nil at this point
<Papierkorb>
And everything else is basically fatal
<Papierkorb>
Bad practice? No, only if it's used in the wrong way.
<RX14>
it wouldn't be there if it was bad practice
<Papierkorb>
If something doesn't have to be nilable in the first place, make it non-nilable
<RX14>
it's just easy to abuse
<Yxhuvud>
it takes some practice before you start writing code that doen't need it everywhere.
eliasjpr_ has joined #crystal-lang
<RX14>
havent written a no_nil! in years :)
eliasjpr_ has quit [Ping timeout: 248 seconds]
<FromGitter>
<exts> but yeah reason I brought up not_nil is because I was getting a compiler error `undefined method X for nil` what's an alternative to not nil for dealing with types that are inferenced as `Type | Nil`
<Papierkorb>
`if var` or `Object#try`
<Papierkorb>
the former is in the language docs.
<FromGitter>
<exts> hmm
<Yxhuvud>
exts: The alternative is having one that is only Type. There are usually ways to acheive that.
<RX14>
"how do you deal with nil" is an entirely unanswerable question
<RX14>
because nil represents so many things
<RX14>
either something which if it's nil it's a bug
<RX14>
or perhaps a user input error
<RX14>
or perhaps just something where you have to try something else
<Papierkorb>
or something optional
<RX14>
the first you have to deal with by raising because it's a real bug
<RX14>
the second you have to communicate with the user
<FromGitter>
<exts> well basically i want to define a class variable without instantiating it right away, but the type ends up being type|nil when you don't
<RX14>
the thord you treat it as an optional and need to do something else
<Papierkorb>
exts, of course, because then it *is* nilable
<RX14>
so the typical pattern there is to use a getter
<Yxhuvud>
exts: you could for example write a getter method that will raise if it is nil, and then always get it from the getter.
<RX14>
which raises on nil, or uses late initialization
<FromGitter>
<exts> yeah exactly, i tried your `if var` didn't work, going to try something to see if i did something wrong
<RX14>
late init is the best because it can never raise
<Papierkorb>
Or a `getter!` for if initialization happnes later, or a yielding getter to lazily intialize it
<RX14>
raise on nil is just getter!
<RX14>
but if you have something like that it's sometimes nice to step back and think about refactoring for a bit
<RX14>
you can usually find a way to get it in through the constructor
<Yxhuvud>
or put it in a different class instead of in a class variable.
<RX14>
oh yeah its a class variable
<RX14>
i dont use them much
<RX14>
hard to test
<FromGitter>
<bew> I'm trying #5244 but I have a question, when to return a StringLiteral and when to return a MacroId ?
<FromGitter>
<exts> @Papierkorb i've tried everything there but Object#try, how come `if a = @a` doesn't work, but should according to that reference example?
<Papierkorb>
it does work.
shankar has joined #crystal-lang
<FromGitter>
<exts> show me using play.crystal-lang.org because i tried it and it didn't work. Object#try worked though
<Papierkorb>
That's not how I works.
<Papierkorb>
I'm *NOT* your personal trainer
<Papierkorb>
you show a code snippet you have an issue with
<FromGitter>
<exts> Alright, sorry.
<FromGitter>
<exts> I posted the snippet above
<Papierkorb>
and someone who has the time and cares will help
<Papierkorb>
that's obviously not the same as in the docs.
<FromGitter>
<exts> sorry let me repost the correct snippet
<FromGitter>
<Sevensidedmarble> So are or aren't global vars supported in crystal?
<RX14>
no
<FromGitter>
<Sevensidedmarble> Because the docs say they are but when I try to use rhem I get a error
<FromGitter>
<Sevensidedmarble> With that many breaking changes there's no need to keep older version docs righr?
<RX14>
we dont keep them on purpouse
<FromGitter>
<Sevensidedmarble> I see
<FromGitter>
<bew> I can't get a hierarchy with the tool of AST nodes, I always get a undefined constant error, even if I do that on all files like compiler/crystal/**/*.cr
<FromGitter>
<bew> anyone knows how I can make it work?
eliasjpr_ has joined #crystal-lang
<FromGitter>
<Sevensidedmarble> Also can we make it so the search bar on the api site searches the content of modules and not just their names?
<RX14>
@bew the macro ast nodes in the docs are fake
<FromGitter>
<bew> not the macro ast nodes, the real ones
<RX14>
oh
<RX14>
rip
<RX14>
should work if you have the right name and require src/compiler.crystal.cr
<RX14>
and use bin/crystal
snsei has joined #crystal-lang
<FromGitter>
<bew> ah using bin/crystal seems to work!
<RX14>
lol...
<FromGitter>
<bew> I'm just gonna use that and stop asking ^^
<FromGitter>
<exts> alright i figured out what I was doing wrong https://play.crystal-lang.org/#/r/31a2 the `if a = @var` syntax wasn't trying to assign 'a' to the @var but rather assign @var to the a variable.
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter>
<exts> thanks for the help, no more `not_nil!` use from me
qard has joined #crystal-lang
<RX14>
why would you think that considering every other assignment sets the variable onm the left to the expression on the right
<RX14>
`if a = @var` is a literal shortcut for `a = @var; if a`
<FromGitter>
<exts> because it's still early and my coffee hasn't kicked in yet
<FromGitter>
<exts> excuse my human error :)
shankar_ has joined #crystal-lang
shankar has quit [Ping timeout: 248 seconds]
shankar_ has quit [Ping timeout: 248 seconds]
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 258 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter>
<Sevensidedmarble> Is #5229 going to be merged aoon then?
<FromGitter>
<Sevensidedmarble> Also do you think there's room in the std lib for an ansii positioning library for parsing by terminals?
<FromGitter>
<Sevensidedmarble> Because that's kinda colorizes wheelhouse and that's in the lib
<FromGitter>
<Sevensidedmarble> And I'm planning on writing one
DTZUZO has quit [Read error: Connection reset by peer]
<FromGitter>
<Sevensidedmarble> Like curses bUT without the curses dependencies
<oprypin>
Sevensidedmarble, neither that nor colorize should be in standard library
<FromGitter>
<Sevensidedmarble> Why don't you like colorize being in the library?
<FromGitter>
<Sevensidedmarble> I think it's super cool
<oprypin>
who said i don't like
<FromGitter>
<Sevensidedmarble> I'm unclear what you mean then
<oprypin>
in my view standard library should be huge but that's not the general consensus
<FromGitter>
<Sevensidedmarble> You just said it shouldn't be thoigh
<FromGitter>
<Sevensidedmarble> Are you saying you like it but most dont?
<oprypin>
yes
<FromGitter>
<Sevensidedmarble> Cuz I agree the std lib should be there to solve problems that there's only one good solution to
<FromGitter>
<Sevensidedmarble> like ansii escape code parsing
<oprypin>
Sevensidedmarble, the problem with that "one good solution" is that you have to make sure it's actually "good" in the first attempt
<FromGitter>
<picatz> Omg, I think I'm finally getting my libpcap bindings to start capturing packets!
<FromGitter>
<picatz> ( with a lot of reading other people's code, of course )
eliasjpr_ has joined #crystal-lang
<FromGitter>
<picatz> This is one of the most magical feelings to get this to finally start working. I was struggling hard-core with this.
eliasjpr_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> cool good job ;)
<Papierkorb>
I also like having a powerful stdlib. Though I actually kinda liked the blessed-and-pulled-in-by-default idea, basically like ruby does it. a good stdlib lib has the opportunity to show how it's done, for people to learn from
<FromGitter>
<simaoneves> @picatz I've seen you asking for help earlier, good to know you are in the right track :)
<FromGitter>
<picatz> Examples of how things are done are hell'a important, at least in my opinion 👍
<FromGitter>
<picatz> And thanks @bew and @simaoneves :D
<Papierkorb>
a good stdlib can also prevent a micro-lib universe like npm. Just say no to leftpad.js
Ryan_ has joined #crystal-lang
<Ryan_>
Hi all, I'm struggling with a JSON mapping. I need to change the following hash from String,Float to String,String so I can output it to a file. Any ideas what I'm doing wrong here?
<Ryan_>
`f = {} of String => Float64`
<Ryan_>
`f.to_json(Hash(String, String)`
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
<FromGitter>
<valenciaj> Hi there!
<FromGitter>
<valenciaj> Can I find help about Crystal here?
<FromGitter>
<Sevensidedmarble> I think it'd make sense for color and positioning to both be part of an ANSII library
<FromGitter>
<bew> yes @valenciaj, welcome!
<FromGitter>
<valenciaj> I'm a newbie with Crystal, but I'm using Kemal and I trying to create a Cache Handler Middleware
<FromGitter>
<valenciaj> But I don't know why the first request it's not closing
<FromGitter>
<valenciaj> Sorry, but the source maybe mangle too much, I try many times
<robacarp>
I'd like to work with a personal fork of a shard on my local machine, and use that fork in another project. Is the shard command setup to do that?
eliasjpr_ has joined #crystal-lang
<FromGitter>
<bew> I think not. but you can symlink the directory where you work on the shard to the `lib/` directory of the project I think
<robacarp>
thats not a bad idea. Will compiles of the "using" project show errors in the lib code then?
<robacarp>
hm, maybe I could monkeypatch the functionality I want in
<FromGitter>
<_JCLL__twitter> @bew without any "require" ?
<FromGitter>
<bew> yes
<robacarp>
actually, I think this shard is breaking convention. shard install creates a folder called granite_orm while cloning the repo clones into a folder called granite-orm
<FromGitter>
<_JCLL__twitter> @bew thx
Yxhuvud has quit [*.net *.split]
dtcristo has quit [*.net *.split]
olbat[m] has quit [*.net *.split]
hmans has quit [*.net *.split]
jeromegn has quit [*.net *.split]
ChickeNES has quit [*.net *.split]
<robacarp>
ln -s ../../granite-orm granite_orm solved it
<FromGitter>
<bew> Ryan_ a file is an IO, so you have access to all methods of IO, including those to read some things (e.g: a string)
<FromGitter>
<bew> ah you probably don't what a string then (string don't allow binary), what do you want to do with the data?
<FromGitter>
<bew> just read to a Slice I think
c-c has joined #crystal-lang
<Ryan_>
I'm moving from a JSON format to binary. I'm storing the string lenght, the string, then a value associated, so it would look like this "4test100"
c-c is now known as Guest76467
Groogy has quit [Quit: WeeChat 1.9]
<Ryan_>
Current JSON is { name: "test", val: "100" }
<FromGitter>
<bew> you'll loose "name" and "val" with this
<FromGitter>
<bew> you should look at how MessagePack does it (for example)
<Ryan_>
That's what I want, I have quite a lot of values to store. Using binary should reduce it
<FromGitter>
<Sevensidedmarble> The editing of lines and autocompletion
swav has joined #crystal-lang
<Papierkorb>
Sevensidedmarble, do you want readline, or do you want something native to crystal?
<oprypin>
Sevensidedmarble, okay so `Readline.autocomplete do |text_typed_so_far|; return ["suggestion 1", "suggestion 2"]; end`, then `Readline.readline(add_history: true)`
<FromGitter>
<Sevensidedmarble> I'll have to take a look at the actual readline api I think, I'm not super familiar with it
<FromGitter>
<Sevensidedmarble> Ive never used the original library either
<Papierkorb>
do you plan on running fibers in the background?
<Papierkorb>
aka, doing asynchronous things?
<FromGitter>
<Sevensidedmarble> I honestly haven't learned how to use fibers yet
<FromGitter>
<Sevensidedmarble> I probably should...
<FromGitter>
<picatz> @Papierkorb -- just out of curiosity, what if the answer was yes?
<Papierkorb>
picatz, then Readline is the wrong choice as it blocks the whole thread and thus, process, when you ask it to read a line
<FromGitter>
<picatz> Very interesting! What would be the "work-around" for something like that?
<Papierkorb>
github.com/Papierkorb/fancyline
eliasjpr_ has joined #crystal-lang
<Papierkorb>
Doing the whole thing in Crystal, of course
<FromGitter>
<picatz> Very cool 👍
<Papierkorb>
appears to be the only shard of this kind yet, or I asked crystalshards the wrong question
<FromGitter>
<picatz> I'll have to play around with it sometime soon. Looks great.
<FromGitter>
<Sevensidedmarble> Your lib looks perfect for what I need Papierkorb
eliasjpr_ has quit [Ping timeout: 264 seconds]
<FromGitter>
<Sevensidedmarble> I'm building a little nix shell
<FromGitter>
<Sevensidedmarble> And I need autocompletion
<Papierkorb>
Then you'll enjoy the tutorial I guess
alex`` has quit [Ping timeout: 255 seconds]
<FromGitter>
<Sevensidedmarble> I didn't even see that yet damn
<FromGitter>
<Sevensidedmarble> That's nice
<FromGitter>
<Sevensidedmarble> I'll link my shell once I have pipes working lol
<FromGitter>
<Sevensidedmarble> Icr should use your lib for autocomplstion...
<Papierkorb>
Make sure to read the docs. You can also generate them by doing `crystal docs` in the checked out shards directory and then open docs/index.html
<Papierkorb>
If the docs don't clarify on something, that's a bug
<FromGitter>
<Sevensidedmarble> Sweet I didn't know about that command
<FromGitter>
<Sevensidedmarble> Can I use that to get the actual crystallang docs too?
<Papierkorb>
erm there was something they did differently. iirc, doing `make docs` builds those..?
<Papierkorb>
But for every normal shard, that command will work .. if the author bothered to write docs :)
<FromGitter>
<Sevensidedmarble> Cause I wish I could get sublime to show docs for methods
<Papierkorb>
Your editor could simply read the embedded in-source docs, which are the basis for the generated version
<FromGitter>
<Sevensidedmarble> Is there any autocomplstion in icr? Because I feel your lib is perfectly suited for that project
<Papierkorb>
I don't use icr
<FromGitter>
<picatz> Even since I was told not to use it: I haven't used it; and I've been just fine.
<FromGitter>
<picatz> But, there's something nice about a REPL that makes me feel all warm and fuzzy inside.
<Papierkorb>
yeah I use `crystal eval` for really quick checks, or just `crystal play`. Its really nice how it tells you what-is-what, which is .. basically more than I expect out of a REPL-ish thing
<FromGitter>
<picatz> `crystal play` is where it's at fo sho 👍
<FromGitter>
<Sevensidedmarble> Oh shit I forgot about crystal play
<FromGitter>
<Sevensidedmarble> That's a good point
<FromGitter>
<Sevensidedmarble> And I didn't know crystal eval existed
<FromGitter>
<Sevensidedmarble> Why we're you told not to use a repl?
<FromGitter>
<picatz> It's not that I shouldn't use a REPL: I love a REPL.
<FromGitter>
<picatz> But, even when you first run `icr`, it'll warn you: it's not perfect.
<FromGitter>
<picatz> Because of these imperfections - which I don't really blame it / or its maintainers for at all - I remember someone telling me not to use it a while back.
<FromGitter>
<picatz> So, I just stopped using it.
<FromGitter>
<picatz> For better or worse, I dunno.
<Papierkorb>
What it basically does is add your most recent input to a temporary file (all previous are written in there too). The whole thing is then ran, and some diff is used to only display the output of the most recent input. Kinda.
<Papierkorb>
Thus, variable values aren't retained in this model, if they still use this model
<Papierkorb>
try this: `a = Time.now`. Wait a few seconds. then just type `a` to output the variables value.
<FromGitter>
<picatz> For some reason when I just tried it in `icr`, I got a `Error: unknown command:`
<FromGitter>
<picatz> 😂
<FromGitter>
<Sevensidedmarble> Right because it's reevaluared the call to time
<FromGitter>
<Sevensidedmarble> But variables that don't use time or http stuff should stay
<Papierkorb>
None really stay
<Papierkorb>
They're all brand-new
<FromGitter>
<Sevensidedmarble> Right
<FromGitter>
<Sevensidedmarble> But the value should be the same
<Papierkorb>
If you make sure they're constant, sure
<FromGitter>
<Sevensidedmarble> It's not perfect yeah, I forgot about crystal play
olbat[m] has joined #crystal-lang
<FromGitter>
<Sevensidedmarble> Does play have auto completion?
<Papierkorb>
nope
<FromGitter>
<Sevensidedmarble> That would be pretty cool
<Papierkorb>
I think ruby broke me. I don't even have it in my editor.
<FromGitter>
<Sevensidedmarble> Why not?
<Papierkorb>
cause the integration for atom sucks
<Papierkorb>
and atom is the least worst editor I know that can do almost everything I expect from an editor
<Papierkorb>
while completely shredding performance
<Papierkorb>
Electron applications. Gotta love them.
<FromGitter>
<marksiemers> Is there a dirty way to access a class variable outside of a class in crystal? And write to it? ⏎ I know it is not good practice, but I think it will be the easiest way to reset the context of something in one of my tests.
<FromGitter>
<Sevensidedmarble> Why not sublime?
<FromGitter>
<Sevensidedmarble> I love atom and vscode too but holy daMN tbeyre slow
<Papierkorb>
I'm a FOSS dev, and thus prefer FOSS to write software
<Papierkorb>
OSS is not as good, but better than closed
eliasjpr_ has quit [Ping timeout: 255 seconds]
<FromGitter>
<Sevensidedmarble> But sublime is so much faster then atom lol
<FromGitter>
<Sevensidedmarble> dont get me wrong I love atom but it dstroys my ram
<Papierkorb>
can I have its source code under a non-closed license?
<FromGitter>
<Sevensidedmarble> I wish trust me
<FromGitter>
<Sevensidedmarble> I hate that it's closed too
<FromGitter>
<Sevensidedmarble> but it's so good
<Papierkorb>
Then it would have to be the cure to cancer for me to consider it
DTZUZU has joined #crystal-lang
<FromGitter>
<picatz> I appreciate that 👍
<FromGitter>
<Sevensidedmarble> It was when it first come out
<FromGitter>
<Sevensidedmarble> That shit was revolutionary to me
<FromGitter>
<Sevensidedmarble> Revolutionary enough that atom and vscode just copied some of its designs blindly
<FromGitter>
<Sevensidedmarble> Shitty ones
<FromGitter>
<Sevensidedmarble> Like json config files
<Papierkorb>
that's really the worst "feature" ever
<Papierkorb>
VSCode at least has the decency of full auto-completion in there
<FromGitter>
<Sevensidedmarble> Yes it is
<Papierkorb>
And atom even topped it with its CSS-selector thing for key combo configuration
<Papierkorb>
like who came up with that and thought it would be a good idea
<FromGitter>
<Sevensidedmarble> Atom would be perfect if it just used qt
<FromGitter>
<Sevensidedmarble> I would love to contribute to this
<FromGitter>
<Sevensidedmarble> This should be in the lib too lol
<Papierkorb>
It's OSS on github, that's just a PR away
<FromGitter>
<Sevensidedmarble> Is there any open issues I could work on?
<Papierkorb>
Easiest thing is adding more classes and everything they need, and then make sure they work as expected
<Papierkorb>
harder, but if you have a Mac and wanna maintain it on mac os, that's something I can't do (Don't own apple stuff)
<FromGitter>
<Sevensidedmarble> No mac unfortunately
<FromGitter>
<Sevensidedmarble> I use fedora
<Papierkorb>
LibEvent integration is missing, which is a roadblock for a 1.0. But it's also non-trivial
<Papierkorb>
^ That integration in Crystal
<Papierkorb>
There's a C++ lib that does it, but it's C++, and would prefer it in Crystal to make things easier for contributors
<Papierkorb>
Um, Fedora, never tried, but .. hopefully works?
<FromGitter>
<Sevensidedmarble> I'll definitely try and report back
<Papierkorb>
something kept me from running Bindgen on fedora for testing, don't remember. You'll need a full bindgen installation to add classes
<FromGitter>
<Sevensidedmarble> Did you write these bindings from scratch or did you use any other language bindings as a reference? Because I know pyqt is very stable
<Papierkorb>
So that's where you wanna start: Get bindgen running on your machine. And then tell me the packages required. if you have Docker, bindgen/ci/ has Dockerfiles for different OS, would be awesome to add Fedora to the list of supported operating systems there. In effect, it almost guarantees at this point that Qt5.cr will work on Fedora
byteflame has joined #crystal-lang
braidn[m] has joined #crystal-lang
Renich has joined #crystal-lang
tybee[m] has joined #crystal-lang
kp666[m] has joined #crystal-lang
thelonelyghost has joined #crystal-lang
TheGillies has joined #crystal-lang
cptaffe has joined #crystal-lang
watzon has joined #crystal-lang
dtcristo has joined #crystal-lang
<Papierkorb>
See github.com/Papierkorb/bindgen
weston_[m] has joined #crystal-lang
sija[m] has joined #crystal-lang
<Papierkorb>
And qt.yml and config/*.yml in the qt5.cr repo for configuration
<Papierkorb>
Um yeah, apart from that, use the bindings, build stuff with it, and if it breaks, report (or PR lul)
<FromGitter>
<Sevensidedmarble> I have literally never used docker
<FromGitter>
<Sevensidedmarble> I never really got the use
<Papierkorb>
That's fine, I also don't use it on my Host lol
<Papierkorb>
It's the defacto standard for containerization. Oh and totally breaks the UNIX principle. Whatever.
<Papierkorb>
It's useful to run stuff on various Linux based OS on a CI though. At least as far Bindgen is concerned.
<Papierkorb>
Could do a similar setup to bindgen for Qt5.cr, would also be kinda nice.
<FromGitter>
<Sevensidedmarble> Yeah ive always just googled the dependencies I need after make fails lol
<Papierkorb>
Besides that, if an interesting use-case comes up that's not covered by a samples/ already, that
<Papierkorb>
I can give you the prelim RHEL package names if that'd help
<Papierkorb>
dunno about fedora, don't both use yum?
<FromGitter>
<Sevensidedmarble> They do yeah bUT I think different repos
faustinoaq has quit [Ping timeout: 260 seconds]
<Papierkorb>
Ah no those were for CentOS. Close enough
<FromGitter>
<Sevensidedmarble> I don't think rhel packages work on fedora
<FromGitter>
<Sevensidedmarble> Thanks I'm gunna test it as soon as I get home
<Papierkorb>
Basically, you need a *full* installation of Clang version 4.0 or later (Later = Better). So, including development headers and libs
<Papierkorb>
Once a `make` in clang/ of bindgen runs through, run the test suite (`crystal spec`) for verification
<Papierkorb>
If that works, you're good to go
<FromGitter>
<Sevensidedmarble> I have
<FromGitter>
<Sevensidedmarble> I have some terminal emulator code I've been writing I really wanna port to crystal now
<FromGitter>
<Sevensidedmarble> And make a qt front end
<FromGitter>
<Sevensidedmarble> What kinda shells do you guys use? Cause I'm writing a shell and I'm ttying to come up with useful features
<FromGitter>
<Sevensidedmarble> I'm a fish user
<FromGitter>
<Sevensidedmarble> So I like weird shells lol
eliasjpr_ has joined #crystal-lang
eliasjpr_ has quit [Ping timeout: 248 seconds]
<Papierkorb>
zsh
<FromGitter>
<Sevensidedmarble> It's really hard to go vack to zsh after using fish
<FromGitter>
<bew> depends on how you configured your zsh imo
<Papierkorb>
zsh (with my config) has been good to me for years, I don't feel like even trying something else
<FromGitter>
<bew> do you use a 'package manager' for you zsh config? (e.g: oh my zsh)
<Papierkorb>
nah
<Papierkorb>
they're way too fat and thus too slow to load
<RX14>
I use one
<RX14>
simply because it makes it easier for me
<FromGitter>
<bew> agree Papierkorb, too slow for me too
<RX14>
i use antigen
<RX14>
my zsh startup used to be really slow
<RX14>
but it's pretty much instant now
<RX14>
half a second at most
<Papierkorb>
And as I use the shell for everything all day long, configuring it for a few hours and then sticking to that for the coming years seemed like a good deal to me
<FromGitter>
<Sevensidedmarble> Zshs autosuggestion library ala fish is just not as responsive as the fish version for me
<Papierkorb>
they're all too slow
<RX14>
autocomplete works
<RX14>
and its fairly fast
<RX14>
i use a pretty heavy prompt
<Papierkorb>
tab completion works great for directories and programs
<FromGitter>
<Sevensidedmarble> It's pretty fast in fiah
<Papierkorb>
But apart from that, nah
<Papierkorb>
if it's not instant it's a no-use
<RX14>
yeah
<FromGitter>
<Sevensidedmarble> It's pretty instant vecause it happens while you type
<Papierkorb>
gn8
<FromGitter>
<Sevensidedmarble> And then you can hit up to go though your history buffer with a fuzzy match
<RX14>
gn8?
<FromGitter>
<Sevensidedmarble> So no need for ctrl r
<RX14>
yeah i have that on zsh but it's a prefix match
<RX14>
less powerful but more predictable
<RX14>
so i can type <command> or just <com and press up and get previous invocations
<RX14>
thats probably the #1 feature of zsh i miss when using other systems
<RX14>
other than my aliases
<FromGitter>
<bew> anyone using fzf (in their shell workflow or other)?
<FromGitter>
<Sevensidedmarble> I use z
<FromGitter>
<Sevensidedmarble> Which is similar
<FromGitter>
<bew> I have z in fzf (way better)
<RX14>
my workflow isnt really very optimized
<RX14>
it's optimized enough
<FromGitter>
<Sevensidedmarble> I'll have to try that Benoit
<FromGitter>
<Sevensidedmarble> What's fzf written in?
<FromGitter>
<bew> go
<FromGitter>
<Sevensidedmarble> I'll have to try it out
<FromGitter>
<Sevensidedmarble> I am also a huge evangelist for Ranger
<FromGitter>
<Sevensidedmarble> itS the best command line thing ever
<FromGitter>
<Sevensidedmarble> I'll definitely check that out when I get home Benoit
<FromGitter>
<Sevensidedmarble> I wanna write something like ranger but with a built in multiplexer
<FromGitter>
<Sevensidedmarble> so you have a terminal right there
<FromGitter>
<marksiemers> RX, my bad on that issue (re: `Hash#key?`) - I was debugging code that expected the wrong behavior ⏎ Shoulda read the docs closer.
<RX14>
not a problem
<RX14>
its a confusing method
<RX14>
unfortunately I can't think of a better name
<FromGitter>
<marksiemers> maybe `key_for` ?
<RX14>
perhaps
<FromGitter>
<marksiemers> Not worth a breaking change, but maybe an alias if people like it
<FromGitter>
<marksiemers> That name, or something else even better