ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
rohitpaulk has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
hightower2 has quit [Ping timeout: 248 seconds]
<Papierkorb> > BUG: trying to assign Int32 <- Pointer(BucketList::Bucket(Pointer(Void)))
<Papierkorb> johnjansen, same here
<Papierkorb> What I do is not hacky at all! ... Well I wouldn't take an oath on it .. err
<FromGitter> <johnjansen> @papierkorb … i found mine …
<Papierkorb> what was it?
<FromGitter> <johnjansen> ill drop some snippets for you ⏎ ⏎ ```module xyzzy… ⏎ l = false ⏎ OptionParser.parse! do |parser| ⏎ ...``` []
<Papierkorb> ?
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <johnjansen> hang on ill pastebin it
<FromGitter> <johnjansen>
<FromGitter> <johnjansen> now there is some trickery going on here involving a proc within the each etc etc, but in essence the ‘i’ from that block was clearly colliding with the var of the same name from the level above … my stupid fault … but it does seem like there is something happening that i dont yet fully understand (like the type of ‘i’ is locked as Bool)
<FromGitter> <johnjansen> im willing to bet you have something similar with a var of type `Int32` who’s name you are sharing somewhere with something you later assign a `Pointer(BucketList::Bucket(Pointer(Void)))` to, possibly in what you would think to be another scope
<Papierkorb> Wish I knew, those are all @@class_vars
<FromGitter> <johnjansen> using a proc anywhere?
<Papierkorb> BucketList isn't, no, and that's the only place where those are assigned
<FromGitter> <johnjansen> crap i got it the wrong way roung
<FromGitter> <johnjansen> -g+d
<FromGitter> <johnjansen> you’ve got a `Pointer(BucketList::Bucket(Pointer(Void)))` that you are trying to assign an `Int32` to
<FromGitter> <johnjansen> the messages are backward i think
<Papierkorb> `SIZE = sizeof(UInt16) * 8` invalid constant value. Are you kidding me.
<FromGitter> <johnjansen> thats ok till you try to assign it
<FromGitter> <johnjansen> — to a constant
<Papierkorb> Using it as argument to StaticArray
<FromGitter> <johnjansen> you cant even `, (8*2)).new 0`
<Papierkorb> I replaced the sizeof with `2` .. and now it works
<Papierkorb> Yeah those rules are a bit crude
<FromGitter> <johnjansen> im betting its because sizeof is not constant so it cant be assigned to a constant at compile time
<Papierkorb> sizeof(UInt16) is probably the most constant thing after a literal you can get
<FromGitter> <johnjansen> yeah … you might have to hard code that one ;-)
<FromGitter> <johnjansen> or do `UINT16_SIZE = 2`
<FromGitter> <johnjansen> unless that is defined somewhere?
Renich has quit [Quit: Renich]
<FromGitter> <fridgerator> what is the syntax to load a shard from the local filesystem?
<FromGitter> <elorest> dep_name: ⏎ path: "path/to/shard/folder"
<FromGitter> <fridgerator> tyty
<FromGitter> <fridgerator> I was using `location`
<FromGitter> <elorest> @fridgerator Glad I could help. Could you look at my PR on amber_cmd?
<FromGitter> <johnjansen> i have so many notes from everyone chatting about stuff like this
<FromGitter> <johnjansen> anyone know of an ftp shard
<FromGitter> <elorest> What's ftp? 😟
<FromGitter> <fridgerator> lol
<FromGitter> <johnjansen> a very old protocol used for domain registrars and govt departments to share semi secure data in an unsecure way
<FromGitter> <fridgerator> can I load a shard over samba?
<FromGitter> <elorest> Looks like it will be included in the stdlib eventually.
<FromGitter> <johnjansen> no @fridgerator but i believe you can over FTP
<FromGitter> <drosehn> macOS also has the `dscl` command, although you need to have some idea of how the Directory Service is set up. Or at least all my Macs have that, I'm not sure if the `dscl` command still exists in Sierra or High Sierra.
<FromGitter> <johnjansen> ;-)
<FromGitter> <johnjansen> JOKE
<FromGitter> <fridgerator> lol
<FromGitter> <drosehn> On my mac, I have a userid 'gad'. I can see that it exists via: `dscl . -list /Users | grep gad`, and I can see all the directory-information associated with 'gad' via the command: `dscl . -read /Users/gad` (which is about a megabyte of information)
<FromGitter> <johnjansen> or wrap
<FromGitter> <johnjansen> or something
<FromGitter> <elorest> @fridgerator Yes you an load over samba as long as the remote drive already has a mountpoint on your OS>
<FromGitter> <elorest> Probably this sort of seems like the kind of thing that should be native.
<FromGitter> <johnjansen> i agree, but dont have the time
<FromGitter> <johnjansen> :-)
<FromGitter> <drosehn> You can also ask for specific items, such as: `dscl . -read /Users/gad RealName UserShell`. If anyone's interested, that should be enough to point you in the right direction.
<FromGitter> <elorest> It would probably be really easy to wrap the `ftp` command in terminal.
<FromGitter> <elorest> just send system calls to it for now
<FromGitter> <fridgerator> thanks guys!! I was just joking about the samba thing though
<FromGitter> <elorest> Dangit. I thought you were serious. I tested it and everything.
<FromGitter> <johnjansen> lol … glad i didnt bother looking into it then
<FromGitter> <johnjansen> haha
<FromGitter> <johnjansen> bad @fridgerator !
<FromGitter> <fridgerator> hhahaha
<FromGitter> <elorest> Well now you know.
<FromGitter> <fridgerator> my bad
<FromGitter> <fridgerator> I was trying to throw something rediculous out there
<FromGitter> <fridgerator> but you guy showed me
<FromGitter> <elorest> If I hadn't been working with nfs a lot at my day job I probably wouldn't have thought you were serious. 🔥
<FromGitter> <drosehn> [going back a few hours] wrt Base64 vs Base91 vs Base122, there's also the Ascii85 format implemented by the `btoa` command written by Paul Rutter, Joe Orost & Stefan Parmark. It's also somewhat interesting note that crystal's `Int.to_s`includes support for base62.
<FromGitter> <drosehn> Hmm. According to , there's a Base85 (described by an RFC at ) which is a revised version of Ascii85, with implementations in C and Python.
<FromGitter> <johnjansen> gotta love crystal, i just replaces `ls` for fun … and with regex matches ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <drosehn> (while the earlier Ascii85 has implementations in 8-10 languages)
<FromGitter> <johnjansen> @drosehn you are not just going back a few hours, but a few years with your knowledge
<FromGitter> <johnjansen> Ascii85 is interesting … im sure the 6 people who used it, loved it at the time ;-)
<FromGitter> <johnjansen> im joking again
<FromGitter> <drosehn> Well, @elorest was talking about Base91 vs Base122 about six hours ago, and I'm just catching up. That reminded me that at one point I used the `btoa` command to encode some binary data which was being sent through ascii email (and had to fix a bug in it wrt 32-bit vs 64-bit platforms).
<FromGitter> <johnjansen> he was indeed
greengriminal has joined #crystal-lang
<FromGitter> <drosehn> So here it is, the first time in weeks that I've had any spare time to look at crystal, and the first thing I do is dream up yet-another project to add to my never-ending list of interesting projects.
<FromGitter> <johnjansen> what did tou dream up
<FromGitter> <drosehn> implementing all of these in crystal, obviously!
<FromGitter> <drosehn> I've been looking at `Int.to_s` for other reasons, and this topic kinda dovetails in with that.
<FromGitter> <johnjansen> add them to the issues in crystal-libraries-needed so we know about them
<FromGitter> <johnjansen> i have a feeling @elorest might start on the one he was talking about earlier .. 91? or close
<FromGitter> <codenoid> morning boiii
<FromGitter> <codenoid> can i do this thing
<FromGitter> <codenoid> ```code paste, see link``` ⏎ ⏎ and call it inside Module []
<FromGitter> <johnjansen> dont know about the query part, or obviously, if data is actually json, or if query one is falsy if it doesnt find something, ⏎ but what i do know is your method returns `(String | Bool)`, `(String|Nil)` might be preferable
<FromGitter> <watzon> @johnjansen out of curiosity is that custom `ls` command available for download? Haha
<FromGitter> <johnjansen> @watzon it will be eventually … at least thats the plan, in the meantime you could pull the repo and build it
<FromGitter> <watzon> Awesome 😁 I’m gonna do just that
<FromGitter> <johnjansen> its called `lsr`
<FromGitter> <johnjansen> regex per path segment
<FromGitter> <watzon> Also, hello everyone! 👋 I’ve been inactive here for a while, but I’m going to hopefully start making some PRs again in the near future
<FromGitter> <johnjansen> accepting PR’s ;-)
<FromGitter> <johnjansen> oh and @watzon for now you need a minimum of the `-l` flag to see anything
<FromGitter> <johnjansen> early days
<FromGitter> <elorest> @drosehn does btoa exist in Crystal.
<FromGitter> <watzon> @johnjansen what still needs to be added?
<FromGitter> <johnjansen> take a look at the option parser for # TODO’s plus its really just thrown together right now, so re-organize, but the primary thing is a default (short) view, with just file names, in columns as per vanilla `ls`
<FromGitter> <johnjansen> its very handy already though (at least for me)
<FromGitter> <confact> Hi guys! i am new here. I am planning to write some ML stuff in crystal :)
<FromGitter> <drosehn> [btoa exists] ah. thanks for the info.
<FromGitter> <drosehn> er, wait, maybe I misunderstood what you wrote. did you mean that `btoa` does already exist? or were you asking a question about it?
<FromGitter> <johnjansen> @drosehn he was asking a question
<FromGitter> <johnjansen> hey @confact check here to see what people are wanting / needing /working on and here and here … and welcome and good luck ;-)
<FromGitter> <johnjansen> you may be most interested in
<FromGitter> <codenoid> wow, why my code works,
<FromGitter> <codenoid> bcoz before this igot EOF error when call that function
<FromGitter> <codenoid> I T S ** M A G I C **
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <watzon> I've been out of the loop for so long I can't remember, does Crystal have anonymous functions?
<FromGitter> <johnjansen> procs
<FromGitter> <codenoid> @sdogruyol can i call session without using env ?
<FromGitter> <codenoid> i mean, i want call and set the session anywhere
<FromGitter> <johnjansen> see the docs on c bindings
<FromGitter> <watzon> Can `shards.yml` include c and c++ dependencies? Or how does that work?
<FromGitter> <elorest> could you link me to a btoa crystal implementation.
<FromGitter> <watzon> @johnjansen I don't think it gives any info in there about where to include the `c` libraries though. Or do they just have to be installed on the machine?
<FromGitter> <johnjansen> man you (@elorest) and @drosehn are totally off the reservation ;-) … ⏎ so @elorest (my friend), there is no `btoa` implementation in crystal, both you and @drosehn are both asking not offering ;-)
<FromGitter> <elorest> Ok. I thought @drosehn said he had used it with crystal.
<FromGitter> <johnjansen> @watzon ive avoided getting into this, so i cant offer anything useful, @elorest might remember the details … i think i was asleep when that was being discussed
<FromGitter> <elorest> shards.yml can't include c or c++ deps. It could however include crystal deps that wrap clibs. You could also run a make file or other script after shard install do install the clib if necessary.
<FromGitter> <johnjansen> @elorest im wondering if there is anything in the code camp slides?
<FromGitter> <elorest> You'd have to test that it worked everywhere though so it's probably better just to tell the user to make sure it's installed.
<FromGitter> <johnjansen> im going to be you need them installed
<FromGitter> <drosehn> Sorry that I gave the wrong impression. Your comments on base91 got me thinking of the `btoa` program which is written in C, and I couldn't remember what "base" was used for `btoa`. I just remembered that I came across it while looking for something better than base64.
<FromGitter> <johnjansen> @watzon grab these for reference
<FromGitter> <elorest> That's a handy comparison chart.
<FromGitter> <johnjansen> dont know how useful they will be
<FromGitter> <drosehn> But then I checked the wikipedia page on binary-to-text encoding, and got to thinking how it'd be nice to have all of those implemented in crystal.
<FromGitter> <watzon> @johnjansen there doesn't happen to be a video of that presentation being given, is there?
<FromGitter> <elorest> No.
<FromGitter> <elorest> If you know C then creating cbinding is pretty easy. If you don't then you'll have to look at the code and google a lot of stuff.
<FromGitter> <elorest> This could help make sense of it from a really base level.
<FromGitter> <watzon> I think this `@[Link(ldflags: "#{__DIR__}/say.o")]` is more or less what I was looking for
<FromGitter> <elorest> Run `gcc -c say.c && crystal`
<FromGitter> <elorest> That's pretty easy to run if you want to play with it as a template for binding 2 different sorts of things.
<FromGitter> <elorest> In that first option you have to create an object file first with `gcc -c say.c` then run crystal and it all works.
<FromGitter> <elorest> You could do something similar with for .a and .so files.
<FromGitter> <elorest> I just modified it to use a macro to compile the c code to and object before linking it.
<FromGitter> <elorest> ```{% `gcc -c say.c` %} ```
<FromGitter> <watzon> Interesting. In a real world scenario that would probably be done with a Makefile though right?
<FromGitter> <watzon> I am definitely a `c`/`c++` beginner
<FromGitter> <elorest> there are a lot of real world scenarios that don't use makefiles but yes that would be a good way to do it.
<FromGitter> <watzon> Anyone have a good example of a shard that wraps a c++ library? I feel like it would help if I could look at a real implementation
balduin has quit [Ping timeout: 240 seconds]
balduin has joined #crystal-lang
<oprypin> johnjansen, CrSFML has FTP lol but it's silly to use for that
<FromGitter> <johnjansen> @oprypin extracting it might not be a bad idea
<oprypin> watzon, yep it is but it's a bit crazy in not making proper C bindings, just hiding the bare minimum like c++ name mangling and c++ standard library
<oprypin> johnjansen, extracting? nah it's a shitty c++ implementation, not worth it
<FromGitter> <codenoid> is crystal have telegram group ?
<oprypin> hopefully not. never heard of such a group.
<FromGitter> <elorest> The ruby one is almost definitely the easiest to port.
<oprypin> elorest, hardcoding gcc and ldflags is nice and all but i hate how people just ignore Windows
<oprypin> and Makefile also doesn't help
<oprypin> y'all need some CMake
<FromGitter> <elorest> Windows is coming back on into the mix and we’ll all figure that out. For years though windows tied it’s self to the .net ide for all development. They’ve made a lot of positive changes lately though.
<oprypin> watzon, generally i would say the C lib has to be already installed, but sometimes people bundle the lib, that seems fragile to me though
<oprypin> if you're a C beginner, binding a C++ library would be a nightmare for sure
<oprypin> not suitable for a first Crystal project either
<FromGitter> <johnjansen> @straight-shoota, did you do a jekkyl dynamic server the other day? if so check out
<FromGitter> <konovod> Just to clarify - there are C++ libraries with C interface though. So, @watzon, if you are talking about library with C++-interface - it's a nightmare like @oprypin says. If the library have C interface - wrapping is easy, no matter what is underlying language.
hightower4 has joined #crystal-lang
<FromGitter> <straight-shoota> Thanks @johnjansen
hightower3 has quit [Ping timeout: 246 seconds]
DissonantGuile has quit [Quit: WeeChat 1.8]
<FromGitter> <sdogruyol> @confact welcome :)
<FromGitter> <sdogruyol> hey everyone
<FromGitter> <sdogruyol> nice trolling :D
<FromGitter> <straight-shoota> ```alias Nim = Crystal``` ⏎ ⏎ :D []
<FromGitter> <sdogruyol> ROFL :D
flaviodesousa has joined #crystal-lang
<Groogy> Morning!
<Groogy> Internet went down in the office for few hours so couldn't access documents I needed to do work, so had PDT with crystal instead ^^
<FromGitter> <sdogruyol> :D
<FromGitter> <sdogruyol> Morning @Groogy
<Groogy> huh for some reason my IRC connection isn't down
<Groogy> wat
<Groogy> everything else is
<FromGitter> <sdogruyol> must be a DNS issue
<FromGitter> <bew> Hey Groogy, nice x)
fazibear has joined #crystal-lang
fazibear has quit [Client Quit]
fazibear has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <codenoid> @sdogruyol can i use env.session without use `|env|`
<FromGitter> <sdogruyol> no
<FromGitter> <codenoid> :( please add that feature
<FromGitter> <sdogruyol> why? There's no way to access the session without a context
<FromGitter> <codenoid> i'mean, access session in every place
<FromGitter> <sdogruyol> that's an antipattern
<FromGitter> <codenoid> like outside `get "/" do |env|`
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <crisward> If it was outside the route, who's session would it belong to?
<FromGitter> <crisward> There is nothing to stop you passing env around.
mark_66 has joined #crystal-lang
balduin has quit [Ping timeout: 255 seconds]
<FromGitter> <sdogruyol> there used to be a .crystal folder for caching .o files
<FromGitter> <sdogruyol> can't seem to find it
<FromGitter> <akzhan> how to get pointer to the symbol in foreign (C) library?
<FromGitter> <akzhan> Looks like $errno : Int32, pointer($errno), will try
<FromGitter> <bararchy> @sdogruyol it was moved to ~/.crystal
<FromGitter> <akzhan> We should replace pcre with onigmo
<FromGitter> <akzhan> I can’t run pcre on macos using UCP option (#4704). But onigmo does.
<DeBot> (Regex can't match utf-8 characters)
<FromGitter> <sdogruyol> @bararchy i don't have ~/.crystal :/
<FromGitter> <sdogruyol> @akzhan how about having a pure Crystal regex engine? :Ş
<FromGitter> <sdogruyol> :P
rohitpaulk has joined #crystal-lang
<FromGitter> <sdogruyol> for example Rust has it's own
<FromGitter> <crisward> @sdogruyol on a mac its ~/.cache/crystal
<FromGitter> <sdogruyol> thank you @crisward :)
<FromGitter> <bararchy> Oh, missed the .cache dir before it
<FromGitter> <bararchy> sorry
rohitpaulk has quit [Ping timeout: 260 seconds]
<oprypin> i put cache in /tmp , don't see why not
<oprypin> this stuff causes a lot of wear to disks
<Groogy> actually on Linux, would putting /tmp on a RAMDisk kind of thing safe?
<oprypin> tmp is ram on arch and some others
<oprypin> maybe Ubuntu even
<Groogy> ah so it is already a ramdisk
<Groogy> cool
<Groogy> is there a command I could use to check so that's true?
<Groogy> hmm don't see an entry for it in my fstab :/
<oprypin> systemd doesn't need fstab. mounts tmp regardless
<oprypin> just check free space in /tmp
<oprypin> I'm having some trouble finding a command to list all mounts
<oprypin> df -h
<FromGitter> <drosehn> what does systemd do with `mount` by itself?
rohitpaulk has joined #crystal-lang
<oprypin> oh i don't think that goes through systemd
<Groogy> ah yepp it is mounted under tmpfs
<Groogy> nice
<Groogy> though I noticed I need to clean out my SSD, it's getting quite filled up
<oprypin> sorry for offtopic - yes, /var/cache/pacman needs periodic cleaning
fazibear has quit [Ping timeout: 255 seconds]
<Groogy> ah lol nah it was my project files occupying all the memory
<FromGitter> <bararchy> ```code paste, see link``` []
<FromGitter> <bararchy> So....
<FromGitter> <bararchy> did I just crashed the Regex engine ?
<FromGitter> <sdogruyol> lol
<FromGitter> <sdogruyol> pcre went wild
hightower2 has quit [Ping timeout: 260 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
fazibear has joined #crystal-lang
hightower2 has joined #crystal-lang
fazibear has quit [Ping timeout: 248 seconds]
Groogy has quit [Quit: WeeChat 1.7.1]
Groogy has joined #crystal-lang
fenicks has left #crystal-lang [#crystal-lang]
greengriminal has joined #crystal-lang
<FromGitter> <akzhan> @sdogruyol implementation of yet another regexp engine has not only benefits. And anyway Rust regex doesn’t support backreferences etc. It’s not easy at all.
<FromGitter> <sdogruyol> yeah, it's hard
Philpax has joined #crystal-lang
<FromGitter> <akzhan> All we need is just to switch to Onigmo that’s built into Ruby. ⏎ Or to enable PCRE PCRE_UCP, but I don’t know how :)
<Groogy> do you guys use regexps on a regular basis in production code? I've always imagined regexp as ultra slow?
<Groogy> though I have nothing to base that fact on, just something I've assumed for a long time
<Groogy> because change is scary
<FromGitter> <akzhan> Exgexps are great for text processing at all. They are built into a lot of languages.
<Groogy> I know was just curious about speed
<FromGitter> <straight-shoota> And they are way easier than writing a custom string matcher/parser, but obviously much slower.
<Groogy> I use them a lot in text documents when I am replacing a lot of stuff in it so I don't have to do it manually
<FromGitter> <straight-shoota> But I think in many applications the potential speed gain is not worth the effort to switch to something else.
<FromGitter> <akzhan> Regexps are fast. With precompilation they sometimes better than hand writing code :)
<Groogy> Right can the compiler in crystal optimize the expression somewhat if it is known at compile time?
<FromGitter> <sdogruyol> LLVM should be smart to do that :P
<FromGitter> <straight-shoota> I don't think so
<FromGitter> <akzhan> No, it’s LLVM task.
<Groogy> Well is it a builtin type in LLVM?
<Groogy> otherwise how would LLVM know what it is to optimize it?
<Groogy> (mind you I do not know much about LLVM)
<Papierkorb> don't we use libPCRE? How should LLVM suddenly optimize a shared library?
<FromGitter> <akzhan> Crystal compiler is very non optimized. But it should be task after 1.0. ⏎ ⏎ LLVM optimizes only known patterns with POD type etc.
<Papierkorb> ..huh?
<FromGitter> <straight-shoota> regexps are handled by libpcre, not llvm
<Papierkorb> LLVMs optimization is ridicolously good, not exactly on the level of GCC, but really good
<Papierkorb> Far better than anything we'd be able to write till 1.0 or whatever.
<FromGitter> <akzhan> But for now Crystal in benchmarks looks as fast as C, and faster than Go etc.
<Groogy> I know, we have a file in our project that Clang will try and optimize the shit out off
<Groogy> so in non-release mode we have to disable optimizations of that file
<Groogy> becuase it takes 45 minutes or some such
<Papierkorb> Look at disassemblies of --release built binaries. For some algorithms, it managed to write x64 assembly that was shorter line-wise than my Crystal code. That's insane.
<Groogy> ow yah is there any OpenGL based libraries for Crystal?
<Groogy> like UI or some such=
<Groogy> I looked before and didn't find anything that seemed.... eh complete?
<FromGitter> <akzhan> Crystal-gl, crystal-raw-gl
greengriminal has quit [Quit: This computer has gone to sleep]
<Groogy> no didn't mean opengl bindings :/
<Groogy> mean like, library that implements drawing a sprite, drawing a button, etc.
<Groogy> or do I need to reinvent that wheel?
<Papierkorb> CrSFML
<Papierkorb> And Crystal is young and UI is terribly complex.
<Papierkorb> Someone has to do that dirty work.
<Groogy> meh I could port my naive C++ GUI library
<Groogy> think I can do it easier with features in Crystal
<Papierkorb> ‎[14:12] ‎<‎Papierkorb‎>‎ CrSFML
<Groogy> no I need a clean OpenGL environment
<Groogy> SFML needs 2.0 and will kind of wreck the environment unless oyu actually push and pop manually the stack
<Groogy> i.e if you combine sfml-graphics with custom OpenGL, you are gonna have a lot of headaches
<Groogy> (not blaming SFML mind you, it's just how OpenGL is built)
<FromGitter> <akzhan> @groogy just google for "crystal lang opengl". ⏎ ⏎ But anyway OpenGL ES is ok, for OpenGL for desktops is something old and supercedes with Vulcan.
Philpax has quit [Ping timeout: 260 seconds]
<Groogy> Eh no actually vulcan doesn't replace OpenGL like DirectX12 replaces 11
<Groogy> Have you tried using Vulcan :P
<Groogy> to be clear with what I mean is, OpenGL is gonna continue to see plenty of use in the future because of the nature of Vulcan API
<FromGitter> <konovod> > SFML needs 2.0
<FromGitter> <konovod> So you need OpenGL 1.0 GUI library? Then library will have a limited use imho.
<FromGitter> <akzhan> I’m work for computer game company but a’m backender :) some people already used Vulcan with Unity.
<Groogy> What no
<Groogy> I would be working with 4.x konovod
<Groogy> but SFML turns on the compability context
<Groogy> akzhan well they are never directly exposed to Vulcan
<Groogy> if you are working with Unity you don't have to manage the command buffers manually I am pretty sure
<FromGitter> <akzhan> Vulcan faster for 35% for one of the games just by switching of renderer
<Papierkorb> They might as well use DirectX, not much would change for the developer
<FromGitter> <akzhan> Of course )
<Groogy> Yeah I am not saying that Vulkan isn't faster?
<Papierkorb> Is that on Windows?
<Papierkorb> Windows drivers are known for their awful OpenGL implementation, especially nvidia
<Groogy> vulkan works on Windows as well yeah
<FromGitter> <konovod> oh. Then it's strange, i was told that sfml is pretty useful even if you draw everything by yourself.
<Groogy> Well point of vulkan and directx12 is the minimal driver implementation Papierkorb
<Papierkorb> So if Vulkan is faster there, no big surprise really
<Groogy> konovod it is
<Groogy> but if you are doing 3D
<Groogy> and you are combining 3D with their graphics package
<Groogy> there is tons of "if's and buts"
<Papierkorb> Groogy: Doesn't change the fact that the OpenGL layers of Windows drivers have been historically crippled to be much slower than it could have been
<FromGitter> <konovod> with vulkan you need ~1000 lines to draw a triangle)
<Groogy> no don't disagree with that
<Groogy> What konovod said
<Groogy> In Unity or similar you won't notice that
<Groogy> If you are just one random guy trying to make something, Vulcan is not for you
<Groogy> unless you have a middleware
<Groogy> just want to be clear konovod, SFML is super good, I've been advocate for it forever and still am. Just pointing out it has it's own problems just like any other piece of software
rohitpaulk has joined #crystal-lang
<FromGitter> <codenoid> ` crystal init app` == crystal made mistake to himself
<FromGitter> <codenoid> can init app remove . (dot) on app name ?
greengriminal has joined #crystal-lang
<FromGitter> <codenoid> THIS IS A REALLY HUG BUG
<Groogy> something like this has to be possible in Crystal :3
<FromGitter> <codenoid> hi groogy
<Groogy> Hi!
<Groogy> o/
<Papierkorb> Groogy: should be. If you just need something event-y, my `cute` shard might help.
<Groogy> oh I might use that if I implement my gui library myself
<Groogy> looks pretty decent Papierkorb
<Papierkorb> Well it *is* modeled after Qt, which *is* (among other things) a GUI lib. So the pattern is proven to work for that
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<Groogy> I'm guessing signal is a macro that generates the nessecary code?
<Papierkorb> It is
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <sdogruyol> wow, this is great
<FromGitter> <sdogruyol> It'd be awesome to have something like this in Crystal
<Groogy> it gives you an IRB like thing at the point where you put in pry.Pry()?
<Groogy> though Go is compiled like Crystal right?
<FromGitter> <sdogruyol> yeah, it's practially pry
<FromGitter> <sdogruyol> yup
<Groogy> pretty cool
<FromGitter> <straight-shoota> Go compiles much faster than Crystal because it doesn't need a huge type inference algorithm and is way more optimized
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> that's why it provides a real-time like response time
<FromGitter> <straight-shoota> yes
<Groogy> I mean most C++ IDE's have an interactive console you can use while debugging
<Groogy> that let's you run C++ code at runtime
<FromGitter> <sdogruyol> @Groogy how come? Incremental compilation?
<Groogy> ¯\(°_o)/¯ haven't really looked into it
<Groogy> I just use it a lot
<Groogy> I mean when you think about it, you have bunch of memory, and if you have the debug data you can easily translate symbols into that memory and then the rest is just instructions to run
<Groogy> it's probably "simpler" than we imagine
<Papierkorb> Aw damn. johnjansen, I found the issue. finally.
<Papierkorb> The code `def foo; yield('0', 0); end; foo{|_, _| }` crashes the compiler.
<Papierkorb> Because _ isn't too special, and instead of complaining about duplicate argument names .. or whatever, really, the compiler crashes
Nouv has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
nikkkk has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <crisward> Anyone know how I specify Proc as a allowed type ie ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <crisward> The error is Proc(String) is not a generic type
<Papierkorb> crisward, the last type argument to Proc is the return value. Use nil if you don't care about it: `Proc(String, Nil)`
<oprypin> crisward, this should be 2 overloaded methods
<FromGitter> <crisward> So I can't just have variable type, and let the compile do the work?
<oprypin> (String->) is same as what Papierkorb said
<oprypin> you can if done right but overload is cleaner
Nouv has quit [Quit: Nouv]
fazibear has joined #crystal-lang
<FromGitter> <krypton97> nice, crystal has generics!
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> Crystal <3
<Papierkorb> And we've been already making good abuse of them <3
<FromGitter> <bararchy> How can I tell the http client to follow redirects ?
<FromGitter> <bararchy> instead of just raising exception
fazibear has quit [Quit: Lost terminal]
<FromGitter> <bararchy> Found that support that :)
<FromGitter> <LuckyChicken91_twitter> how can I import my shard to github?
<FromGitter> <straight-shoota> LuckyChicken, create a repo and push it there
<FromGitter> <straight-shoota> or what do you mean?
snsei has quit [Remote host closed the connection]
<FromGitter> <LuckyChicken91_twitter> how can I push it there
<FromGitter> <LuckyChicken91_twitter> i created already one
snsei has joined #crystal-lang
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium]
<FromGitter> <straight-shoota> you add your github repo as a remote to your local git repo and push
<FromGitter> <johnjansen> @bararchy i was waiting for that ;-) hows the crawler going
<FromGitter> <johnjansen> anyone got an `OptionParser#invalid_option` handler to sort out multiple flags sent as one flag i.e. -> `-lsA` -> `-l -s -A`
<FromGitter> <johnjansen> or another approach ...
<FromGitter> <bararchy> what ? ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <johnjansen> setting a constant with a variable
<FromGitter> <bararchy> The error can be a "little" more clear about that lol
<FromGitter> <johnjansen> haha yeah
<FromGitter> <johnjansen> another one like this came up last night `SIZE = sizeof(UInt16) * 2` which all seems pretty constant, but seemingly is not when your then try to `AR = StaticArray(Int32, SIZE).new(0) # SIZE is 0 right now … who knows why`
<Papierkorb> Is it for you? For me, the compiler didn't like `SIZE` at all there and complained (didn't crash though)
<FromGitter> <johnjansen> @papierkorb, i got a better error report when i hacked around a bit …
<Papierkorb> johnjansen, found my crash bug from yesterday btw
<Papierkorb> (har har 4711)
<FromGitter> <johnjansen> beautiful … and so tricky to spot
<Papierkorb> The Haskell uni class fooled me into thinking that `_` was special in Crystal >_>
<FromGitter> <sdogruyol> Why
<FromGitter> <johnjansen> yeah `_` as a var name should have some special significance or be disallowed
<Papierkorb> in Haskell, _ is truly special as in, the compiler ignores whatever it was. In Crystal, it's a perfectly fine symbol name and is not special apart from convention
<Papierkorb> sdogruyol ^
<FromGitter> <johnjansen> even though the approach is promoted, given these kinds of cryptic failures ensue
<Papierkorb> I'm wondering if it would be possible to make the compiler make a guess where the issue is in the source code on a compiler crash. Would maybe speed up the process of finding the issue
<Papierkorb> Took me ages to figure out my #find method itself was fine, and the issue had nothing to do with Pointer stuff
<FromGitter> <johnjansen> @papierkorb might be a handy starting point for a hack … `SIZE = sizeof(UInt16) * 2` works when i use that macro to create a staticarray
<Papierkorb> johnjansen, that will work, yup. I did something similar in my code, `{{ @type }})` doesn't work, but if you enclose it in {%begin%}{%end%}, it works fine. Kinda funky how you can change the flow of the macro expansion vs. special-method resolution
<Papierkorb> I mean good thing you can, but I wouldn't be surprised if others would find no solution there
<Papierkorb> TL;DR: If macro code doesn't work, repeat adding begin/end until it works
<FromGitter> <johnjansen> yeah thats kind of hard to explain even … its going to come up again … and again …
<oprypin> johnjansen, OptionParser should be able to sort out `-lsA`
<Papierkorb> macro Number.slice <- wat?
<FromGitter> <johnjansen> @oprypin doesnt work from what i can see
<Papierkorb> Surprised there's a special macro for that
<FromGitter> <fridgerator> question about binding to a c library, only the `fun` definitions get bound?
<FromGitter> <fridgerator> nvmd
<FromGitter> <fridgerator> anyone here familiar with netcdf format?
hightower3 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
mark_66 has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
balduin has joined #crystal-lang
<FromGitter> <konovod> Actually, var `_` is already special - it can't be read.
<hightower3> Hiyo, what do I use in Crystal instead of Socket.gethostname?
<FromGitter> <sdogruyol> that's still not available in STD
<FromGitter> <konovod> `System.hostname`
<FromGitter> <sdogruyol> from socket or system?
<FromGitter> <konovod> oh, sorry) for socket no
<FromGitter> <sdogruyol> this issue is open for nearly 2 years
<FromGitter> <sdogruyol> :( :(
Groogy2 has joined #crystal-lang
Groogy has quit [Disconnected by services]
Groogy2 is now known as Groogy
Groogy_ has joined #crystal-lang
<Groogy> home! time for Crystal
<FromGitter> <sdogruyol> wohoo, go for it @Groogy
La has joined #crystal-lang
La has left #crystal-lang [#crystal-lang]
<FromGitter> <johnjansen> ok, can someone point me in the right direction … ⏎ i want to read STDIN when my app starts, but exit if nothing is piped into it, as it stands it waits
<Groogy> what's the crystal standard in project structure for files that should be distributed with the binary but is not source code or a binary?
<Groogy> @johnjansen, #peak maybe?
<Groogy> peek*
<FromGitter> <johnjansen> tried that @Groogy … sorry
<RX14> @johnjansen what's the usecase here?
<RX14> you can detect if STDIN is a terminal with #tty?
<RX14> but i'm not sure about detecting pipes, likely possible
<FromGitter> <johnjansen> ok hang on, let me try
<FromGitter> <johnjansen> that did it thanks @RX14 ⏎ ⏎ ```exit if STDIN.tty? ⏎ STDIN.each_line do |line| ⏎ puts "line => #{line}” ⏎ end``` []
<RX14> whats's the reason?
<FromGitter> <johnjansen> just figuring out the nicest way of handling a situation
tzekid has joined #crystal-lang
<Groogy> there's no way to have `crystal run` take in a working directory as well?
<RX14> no
<RX14> just cd there
<Groogy> well I am setting things up in my editor so it runs things for me
<Groogy> so doesn't make it 100% straight forward
<RX14> well
<hightower3> Hey why is there no #each for NamedTupleLiteral?
<RX14> Groogy, if your editor's scripting run function doesn't take a working directory it's weird
<Groogy> It's VS Code
<Groogy> the tasks doesn't seem to have a value for that
<RX14> well i imagine there's a a way to do it
<Groogy> yeah I'll fiddle around
<FromGitter> <johnjansen> so @RX14 that worked out beautifully, as an experiment ⏎ ⏎ ```$ ./lsr ^zones$/^[0-9]{8}\-$ | xargs cat | ./icann_zone_parser > icann.txt``` []
<RX14> thats cool
<FromGitter> <johnjansen> dont know if thats how it will be in the end … but yeah, kinda cool
<FromGitter> <johnjansen> cron it and im almost done ;-)
<FromGitter> <peterschols> Dear Crystalers, I wanted to let you know that we've just deployed our first Crystal app into production. The Crystal app is part of our genome analysis platform which is being used by geneticists worldwide to diagnose patients with rare genetic conditions. More info is available at ⏎ I want to thank all of you for developing Crystal, nurturing the Crystal community and last but
<FromGitter> ... not least for answering my questions here on Gitter ;) ⏎ We've also added our company to the Used in production page at
<FromGitter> <johnjansen> 👏
<RX14> thats super cool
<FromGitter> <sdogruyol> Wow, that's great @peterschols. Congrats 🎉
<hightower3> No microsecond precision in Time yet?
<FromGitter> <peterschols> @sdogruyol @johnjansen RX14 thanks!
<RX14> hightower3, time is precise to 1/10th of a microsecond
<RX14> i.e. there are 10 time ticks in 1 microsecond
<RX14> we've discussed nanosecond precision for Time but i'm not entirely sure it's worth it
<hightower3> RX14, oh, of course, my bad. I was looking at the seeming unavailability of #usec or similar, to get the microsecond value
<hightower3> but ticks/10 would sure work
<hightower3> thanks
<RX14> yeah it's kinda weird that it doesn't expose it
<RX14> my latest PR actually adds Time::Span::TicksPerMicrosecond
<RX14> so you should switch to ticks / Time::Span::TicksPerMicrosecond for portability going forwards
<RX14> or at least leave a TODO
<RX14> hopefully i'll get that change in next release
<FromGitter> <fridgerator> @peterschols 👍
<Groogy> can I from a value, access a subclass in it? I.e this is obv wrong but sense of what I am asking ""
sz0 has joined #crystal-lang
<FromGitter> <bew> Not sure it's possible, what's obj type(s)?
<Groogy> Version
<Groogy> class Version
<Groogy> or wait no it's Struct nevermind
Ven has joined #crystal-lang
Ven is now known as Guest69722
Guest69722 is now known as Ven``
<FromGitter> <paulcsmith> @peterschols That's awesome! Did you use Kemal?
<FromGitter> <elorest> @peterschols That super cool.
<FromGitter> <elorest> Any word on asterite disappearing from twitter yet? How are sourceforge donations split up now I wonder?
balduin has quit [Ping timeout: 258 seconds]
<Groogy> hmm why can't I get a variable have less of a defined union type?
<oprypin> > sourceforge
<Groogy> i.e like an Array(Int32) become an Array(Int32 | Float64)
<oprypin> Groogy, cuz nobody programmed that. and it's not obvious whether it even should be like that
<oprypin> it can't become that because its memory layout is different, you'd need to copy it anyway
<Groogy> hmm :/ THen I am curious how does the YAML::Any work?
<oprypin> it has all those types programmed in in advance
<oprypin> Groogy, from a value you cannot access a subclass in it
<Groogy> yeah but I am trying to replicate similar behaviour, I've defined alias Type = Int32 | Float64 | String | Hash(Type, Type) | Array(Type) | Nil
<Groogy> but it won't let me assign a Array(In532) to it
<oprypin> anything preceding :: must be an uhh identifier starting with an uppercase letter
<oprypin> Groogy, yes, it will not. as I was saying, these have an entirely different memory layout
<oprypin> Array(Int32 | Float64) contains a sequence of 12-byte items typeid of 4 bytes and data of max(4, 8) bytes
<oprypin> Array(Int32) contains a sequence of 4-byte items of data
<Groogy> well it manages for String and array :/
<oprypin> no it doesnt
<oprypin> Groogy, anyhow, use [1, 2, 3] of Type
<oprypin> or a = [1, 2, 3]; &.as(Type)
<oprypin> that will enable the expected memory layout, in the 2nd case by copying
<Groogy> thanks
<oprypin> Groogy, i keep blabbering about the memory layout - that's how i'm justifying the lack of this kind of cast, and why it seems to be impossible to reasonably implement, but i may just be missing something and i don't dismiss the possibility of this feature
<Groogy> eh well it would be weird if it is an actual C style union in memory after compilation time
<Groogy> I mean I rationalise it works like Templates, then you will just generate a new variant of the method on each type
<Groogy> now to just convert it to YAML::Type, sigh
<oprypin> Groogy, but hold on, you do realize that Crystal's unions are in fact exactly like actual C style unions in memory?
<Groogy> the type unions?
<Groogy> not the union unions
<oprypin> yes
<Groogy> I was refering to the type unions
<oprypin> me too
<Groogy> well that's kind of pointless?
<oprypin> Groogy, uh these also store the type id. i forgot that it's not required to have that in C unions
<oprypin> each type has a unique type id
<Groogy> No type id's are for referenced objects only right?
<oprypin> all types
<oprypin> damn i gotta finish that article, now i have yet another thing to add to it
<FromGitter> <renich> I think I've found a bug in playground. If you create a file in `playground/` and leave no new line at the end, when loading it through `crystal play > workbook` it will append "```" to the end of the last command.
<Groogy> Eh you sure? Because I remember specifically reading about the SuperClass+ being the one with the type id?
<hightower3> RX14, actually, looking at the microseconds thing, I basically need the microseconds value of (just the part after the dot)
<RX14> Groogy, all unions (apart from Reference | Nil which is optimized as nullptr) are tagged with a type id
<RX14> classes contain a type ID in their beinary representation too
<RX14> but structs do not
<oprypin> Groogy, i'm not messing with ya
balduin has joined #crystal-lang
<Groogy> that's kind of a waste?
<RX14> why
<hightower3> RX14, not sure how to best obtain that, e.g. if the #epoch_f gives 123.456789, I need "456789"
<RX14> how else do you tell what the union represents
<Groogy> until you add in polymorphism you can solve that by just solving variations of the functions. I just imagined every method in Crystal was a template function which would have the same effect
<Groogy> which was why I thought the union of a SuperClass+ meant
<RX14> what?
<RX14> you realise which method to call is decided at runtime
<RX14> not at compile time as with java and co
<RX14> it's called dynamic dispatch
<RX14> oh no
<RX14> it's multiple dispatch
<RX14> i'm clearly tired
<Groogy> It doesn't do like D then which at compile times which methods need to be decided on runtime and which ones does not?
<Groogy> i.e it will still resolve Int32.+ at runtime?
<RX14> well yes of course
<RX14> if there's no union it doesn't need to do multiple dispatch
<RX14> and it's just a typical method call
<Groogy> Yes same applies with how templates work in C++
<oprypin> Groogy, you have to realize that C++ has nothing that's even close to Crystal's type unions
<oprypin> other than actual unions, of course
<RX14> doesn't C++ have tagged unions as a datatype in it's stdlib
<RX14> i'd say thats clode
<RX14> but obviously you need to dereference that manually
<Groogy> It does, it's called templates, though they do not define specific types but it is possible to replicate similar behaviour in certain circumstances
<RX14> so not close in utility
<oprypin> Groogy, no, templates are not that
<Groogy> You can get similar behaviour in C++ with templates is what I said
<oprypin> you cannot
<RX14> are you sure oprypin
<Groogy> i.e I can create a function that will call the same function on vastly different types
<oprypin> Groogy, and you have to know the exact type at compile time
<oprypin> RX14, i am about 97% sure
<oprypin> also no, c++ does not have tagged unions, you can just write your own adhoc type id as the first struct member
<RX14> it doesn't have them as part of the language
<Groogy> Yes? And the Crystal type inhference algorithm can deduce correct type from me just doing stuff like if var.is_a?(stuff)
<RX14> but it's part of the stdlib
<RX14> i'm pretty sure
<oprypin> Groogy, so it can
<RX14> yeah C++ will never be able to do that oprypin
<RX14> if thats what you're saying
<oprypin> and when it can't, e.g. when you have a variable of type (Array(Int32) | Int32) and call .to_s directly on it without is_a, that's when runtime type id checking comes in
<Groogy> but you can reduce it to paths where the same function is being called where it is directly an int32 or an Array(Int32), how can it not reduce the type then like it does in C++? I.e generate the variations by itself like C++
<Groogy> because that is what was happening for me
<Groogy> right
<oprypin> i have no idea what magical c++ feature you are talking about, you'd have to provide an example
<Groogy> i.e the code I have written is qualified to work both with an Array(Int32) and an Int32, so for Crystal to allow me to just provide it with either an Int32 or an Array(Int32) and it should work
<Groogy> but apparently it doesn't, I have to say it is a union of every type
<Groogy> For C++ it would just have generated a variant of every instance that you call on it
<Groogy> if it succeeds generating that is
<RX14> yeah i'm very confused rn
<oprypin> i'm convinced that only Groogy is confused
<RX14> ah but i'm confused at what Groogy is confused about
<Groogy> no
<RX14> Groogy, what do you mean by "I have to say it is a union of every type"
<FromGitter> <sdogruyol> lol :D
<RX14> are you referring to crystal or C++ here
<Groogy> Crystal
<oprypin> Groogy, just provide any example where you think c++ does something that crystal can't, and we'll show you why that's not the case
<Groogy> THe problem I had with YAML is that I had to make a Array(String) into a YAML::Type which includes the previous mentioned type
<oprypin> (yes, c++'s runtime polymorphism may be more performant due to vtables, but that's about it)
<Groogy> this would define two different functions, one for Int32, one for Array(Int32)
<oprypin> ok
<Groogy> I.e in essence it can take a "type union of array int32 and int32"
<RX14> an Array(String) isn't and will never be an Array(YAML::Type)
<RX14> they havbe entirely different binary layouts
<oprypin> RX14, i've talked enough about that above
<RX14> this means in crystal a function expecting YAML::Type will take an Array(String)
<RX14> because it can be templated like you say
<RX14> but an instancae variable cannot
<Groogy> no it can't RX14
<Groogy> I just tried
<Groogy> that's what I was pointing out
<RX14> :thinking:
<oprypin> now that's a valid point
<oprypin> RX14, Array(String) is simply one of the items in YAML::Type
<hightower3> RX14, can't find your PR with TicksPerMicrosecond
<RX14> hightower3, it's part of a large PR
Groogy has quit [Quit: WeeChat 1.9]
<RX14> oprypin, yes but thats what Groogy_ is saying though right
Groogy has joined #crystal-lang
<Groogy> weechat froze for some reason, stopped taking input
<Groogy> what did I miss
<RX14> <RX14> :thinking:
<Groogy> Either way I tried that before and couldn't get it to work
<oprypin> even this works? wut
<hightower3> RX14, found it, thanks
<oprypin> since when
<Groogy> hooow
<Groogy> I tried before
<RX14> oprypin, it's a function
<Groogy> maybe it's when saving to a variable?
<Groogy> ah yeah
<Groogy> it is when saving to a variable
<RX14> function behaviour and ivar behavior are not the same
<RX14> here crystal just creates a new function for each applicable binary layout
<RX14> so it can be a lot more flexible
<RX14> however thats obviously impossible with ivars
<oprypin> RX14, i know that
<Groogy> yeah no the property :value made the message associated with the method generation
<Groogy> which made it directly connected as I was reading it in my head
<oprypin> >> [1, 2, 3].is_a?(Array(Int32 | String))
<DeBot> oprypin: # => false -
<RX14> yep oprypin
<oprypin> so why is it accepted as an argument if it's not a
<RX14> there's an issue on this
<Groogy> because is_a? is used to make the type more narrow I guess?
<Groogy> ah
<RX14> i think it's called covariance and contravariance
<RX14> but i'm not sure if those are the right terms
<RX14> is_a? uses the ivar definition of type
<Groogy> it actually does a runtime check I guess
<RX14> or actually no
<Groogy> while the method is done in compile time
<RX14> no not really
<RX14> is_a? just turns into "is the type ID in this list" iirc
<RX14> so its effectively compiletime
<RX14> remember crystal has no vtables
<Groogy> eh though it has to return true in runtime to know if that branch is to execute or not?
<Groogy> if it is an ivar and don't know the value at compile time?
<RX14> yes Groogy thats why i said it turns into a type_id lookup
<RX14> the type_id lookup is at runtime
rohitpaulk has quit [Remote host closed the connection]
<RX14> but the compiler knows the all the type ids which match
<RX14> which means all the real logic is done at compile time
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest79280
Guest79280 has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
<hightower3> I have code like a, b = string.split(":"), but there might be no ":" in the String, in which case I get Index out of bounds error. What's the best/optimal way to prevent that? If there is no ":", b should be nil.
<Papierkorb> Huh destructuring arrays?
<Papierkorb> hightower3: Split, then check the arrays length, then fill a, b as wanted
<FromGitter> <peterschols> @paulcsmith @elorest Thanks! ⏎ @paulcsmith We're not using Kemal for now, the Crystal app is used for backend genome analysis. We use Rails as a 'front-end' for the UI. We are looking into projects like Kemal or Amber though and we might use them in the future.
<oprypin> hightower3, use partition or rpartition
Ven_ has joined #crystal-lang
<hightower3> Papierkorb, can't split, the split line itself produces the error:
<oprypin> hightower3, I strongly disagree with "b should be nil", you haven't given it enough thought.
<Papierkorb> hightower3: I meant to treat the array result as array and then check it.
<hightower3> oprypin, yes I agree, it can be "" and partition would do fine
<hightower3> Ok, understood.
<hightower3> partition will do good here, thanks!
<Groogy> is there a #map variant for Hash?
<oprypin> variant?
<Groogy> i.e #map defined for hash, or something to accomplish something similar
Nouv has joined #crystal-lang
<oprypin> yes. Instance methods inherited from module Enumerable({K, V})
<oprypin> interestingly enough the linking is broken
<Groogy> it says it creates an array though?
<oprypin> Groogy, indeed it does
<oprypin> can do .to_h on it
<Groogy> though all I want is to convert the key&values to values that YAML is okay with
<Groogy> so would like it to remain a hash
<Groogy> ah it's #select
<Groogy> I think
<oprypin> no
<oprypin> obviously you'd need to make a new hash out of it (memory layout and all), and there's no direct way to do a conversion in one method from the standard library
<Groogy> nah it's not aw :/
<oprypin> you either do .map .to_h or you do it yourself in a loop
<oprypin> for best performance `typeof(hash).new do |new| hash.each do |(k, v)| new[k] = v; end; end`
snsei has joined #crystal-lang
greengriminal has joined #crystal-lang
<RX14> hightower3, the stdlib also does as Papierkorb suggests
<RX14> but there has been proposals for some way of destructuring the way you wish
<RX14> using a syntax like a, b? = string.split(":")
<hightower3> mm, that would be pretty nice
<RX14> although i think it's somewhat unlikely to be implemented any time soon
Ven_ has quit [Ping timeout: 248 seconds]
<FromGitter> <konovod> lol, the error is scary:
<FromGitter> <konovod> and i can't reproduce it on llvm 4.0. will try later to get same envirnment and identify minimal example
Nouv has quit [Quit: Nouv]
<Groogy> Hmm the YAML in crystal seem to write everything in one line :/ Is there any way to tell it to write it "pretty"?
<Groogy> or hmm must be doing something wrong since examples seem to show the output in the format I would expect
<oprypin> Groogy, are you on Windows or something
<Groogy> no arch
<Groogy> result I got though was: {"graphics" => {"backend_version" => ["3", "3"]}}
<Groogy> which seems bit odd
<oprypin> Groogy, that's just .to_s
<oprypin> >> {"graphics" => {"backend_version" => ["3", "3"]}}.to_s
<DeBot> oprypin: # => "{\"graphics\" => {\"backend_version\" => [\"3\", \"3\"]}}" -
<Groogy> hmm
<Groogy> hmm that's weird, my to_yaml has to be wrong then
<oprypin> Groogy, easiest would be to pastebin everything as one file
<Groogy> nah figured it out, the IO given to the to_yaml is literally the IO, I was expecting it to be a stream class from YAML that would parse the objects
<Groogy> aaand that fixed it
Ven has joined #crystal-lang
Ven is now known as Guest24175
snsei has quit [Remote host closed the connection]
<FromGitter> <elorest> What is the best way to add into a slice of bytes. It seems as if slices are a contant size where as an array lets you append.
<oprypin> elorest, it's true, they are constant size
<oprypin> you can gather data in an IO::Memory and then to_slice
<oprypin> elorest, FYI arrays use a constant size memory region under the hood and just occasionally move to a new, bigger constant size memory region
<oprypin> and IO::Memory is that array-like thing that you're looking for
A124 has quit [Ping timeout: 260 seconds]
hightower3 has quit [Ping timeout: 260 seconds]
hightower3 has joined #crystal-lang
nikkkk has quit [Quit: Textual IRC Client:]
<FromGitter> <elorest> <oprypin> that makes sense. Thanks.