<FromGitter>
<rmarronnier> There is no complex logic in the regex but it was more convenient (and maintainable) using one expression per script than reimplementing a regex match with code (withunicode characters ranges etc.)
<FromGitter>
<sam0x17> gotcha
<FromGitter>
<sam0x17> also have you tried pasting the raw characters into the code and seeing what happens?
<FromGitter>
<sam0x17> that is the first thing I would try even tho prob wont work
<FromGitter>
<rmarronnier> hmm, so my IDE would translate those characters in their utf-8 values ?
<FromGitter>
<sam0x17> maybe?
return0e has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
<FromGitter>
<rmarronnier> Thanks for the ti, but I find it too hackish :-D I'll limit myself to UTF-8 for now but I'll keep my eyes open for a PCRE UTF-16 flag added to the Crystal Regex :-)
<FromGitter>
<rmarronnier> *tip
_whitelogger has joined #crystal-lang
<FromGitter>
<watzon> I was under the impression that hashes should be unique across objects, but it's looking like that's not the case
<FromGitter>
<sam0x17> has anyone tried defining the members of a type union via macro? tips tricks pitfalls?
<FromGitter>
<Blacksmoke16> hm?
<FromGitter>
<sam0x17> as in, I am going to try to have some macros that add members to a type union, so that the union will have only the needed members as determined at compile time based on what macros get called
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<Blacksmoke16> still not sure i follow, but gl :P
<FromGitter>
<watzon> Ahh yeah, that's what I'm looking for
<FromGitter>
<Blacksmoke16> got an example? :P
<FromGitter>
<sam0x17> so i.e. if this was for an ORM, it would be like a standard ORM setup with a huge type union, except the type type union will ONLY have the types that get mentioned in all the column definitions collectively
<FromGitter>
<Blacksmoke16> in a hash?
<FromGitter>
<sam0x17> so if there is no column that includes Int64, Int64 won't be in the union for that compilation
<FromGitter>
<sam0x17> yeah, theoretically
<FromGitter>
<Blacksmoke16> isnt that how it just works already?
<FromGitter>
<Blacksmoke16> er nvm
<FromGitter>
<sam0x17> and it would be per model
<FromGitter>
<sam0x17> so the unions would be quite small
<FromGitter>
<sam0x17> ty ty I would have done some dumb string manipulation to join on " | " probably xD
<FromGitter>
<Blacksmoke16> np :P
<FromGitter>
<sam0x17> but yeah this is for a non-orm purpose, the ORM analogy just fits perfectly
<FromGitter>
<Blacksmoke16> really you just need to get an array of the possible types
<FromGitter>
<Blacksmoke16> which is easy if they are ivars
<FromGitter>
<Blacksmoke16> but other catch is it only works within context of a method
<FromGitter>
<sam0x17> ah ok
<FromGitter>
<sam0x17> I'll probably have to do constant re-opening then I'm guessing
<FromGitter>
<Blacksmoke16> make a module that defines it when its included
<FromGitter>
<sam0x17> yeah that's the plan, or are you saying I can avoid constants within a `macro included` block?
<FromGitter>
<sam0x17> *avoid needing constants
<FromGitter>
<Blacksmoke16> that was the idea, then just include that and it just works?
<FromGitter>
<Blacksmoke16> i.e. the module defines `def to_h` that you can use to build the hash from the types ivars?
<FromGitter>
<sam0x17> yes, thanks this helps a lot
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<shinzlet> I have an issue with some YAML stuff I wanted to talk out with someone more experienced, but I'm not sure if this is the right place for questions. Is it okay if I ask here, or should I get out of your collective hair?
<FromGitter>
<Blacksmoke16> sure whats up
<FromGitter>
<watzon> @shinzlet this is the place, ask away
<FromGitter>
<shinzlet> I'm working on a little project right now where I need to work with a yaml data file. I need to have a way to create it if it doesn't exist, read from it if it does, and modify it. I figured the best way to do that would be making a `Config` class that includes YAML::Serializable, and giving all the properties default values. Then, if I wanted to create the nonexistent YAML file, I could just serialize a
<FromGitter>
... `Config.new` using the `to_yaml` method and write it to disk. It would also allow me to read the config with `from_yaml` and modify it as it if were an object (`Config.foo = "bar"`). When I actually do this, though, I run into a bunch of problems with trying to instantiate a `Config` using `Config.new`. The compiler tells me it ... [https://gitter.im/crystal-lang/crystal?at=5d5f4866c508da44c365f3b9]
<FromGitter>
<watzon> I'll let @Blacksmoke16 handle this one, he is the master of serialization
<FromGitter>
<shinzlet> Haha, sounds good. @Blacksmoke16, I have a minimal example of what I'm talking about if you'd like it.
<FromGitter>
<Blacksmoke16> lol yea
<FromGitter>
<Blacksmoke16> just add
<FromGitter>
<Blacksmoke16> `def initialize; end`
<FromGitter>
<Blacksmoke16> to your class
<FromGitter>
<Blacksmoke16> :S
<FromGitter>
<shinzlet> Ohhh, thank you! I had actually tried overwriting self.new, but it didn't go smoothly
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<Blacksmoke16> however just know that you cant really edit the file as if it was an object
<FromGitter>
<Blacksmoke16> you would ofc have to resave the obj to disk
<FromGitter>
<Blacksmoke16> editing the obj isnt going to keep the yaml file in sync
<FromGitter>
<shinzlet> Yup, yup - I just needed help with actually getting a modifiable object into memory
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<shinzlet> I'm Canadian, so it feels wrong to not get another thank you in - thank you
<FromGitter>
<Blacksmoke16> eh
<FromGitter>
<Blacksmoke16> 😉
<FromGitter>
<Blacksmoke16> one idea is to define a method on the obj like `def save`
<FromGitter>
<nsuchy> @Blacksmoke16 would this in theory make Amber websites faster
<FromGitter>
<nsuchy> since different threads could handle different connections and requests
<FromGitter>
<Blacksmoke16> i think amber already does that internally, by forking the process. However i dont know much about any of it so :shrug:
<FromGitter>
<Blacksmoke16> afaik that would be like a single process using multiple threads, while forking would be running multiple instances of the same process
<FromGitter>
<nsuchy> Sounds like it would make crystal code cleaner
<FromGitter>
<nsuchy> rather than relying on a bunch of sub processes or whatever
<FromGitter>
<Blacksmoke16> guess we'll have to wait for the dev blog :)
<FromGitter>
<Blacksmoke16> isnt that what i said like 30min ago? :p
<FromGitter>
<tenebrousedge> yes
<FromGitter>
<dscottboggs_gitlab> yeah I tried `Array(Int32) | NestedArray` in response to that @Blacksmoke16 and that obviously still didn't work. sorry for misunderstanding you
<FromGitter>
<Blacksmoke16> <3 np
<FromGitter>
<ikaru5> Hello guys, can someone please help me with macros? Im looking for a way to share information between the macro definitions... ? Any chance? Somethink like instance variables for macros?
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> well
<FromGitter>
<Blacksmoke16> you mean like
<FromGitter>
<dscottboggs_gitlab> there are macro variables and all constants are available in macro land
<FromGitter>
<watzon> Lol I've got someone telling me that Crystal is already multithreaded because fibers
<FromGitter>
<tenebrousedge> be gentle :/
<FromGitter>
<watzon> And that the MT PR is just adding unnecessary bloat to the language
<FromGitter>
<dscottboggs_gitlab> oooof
<FromGitter>
<Blacksmoke16> hehe
<FromGitter>
<wontruefree> well it is either someone who doesnt know because no one has taught them or someone has told them and they just think they know better .....
<FromGitter>
<watzon> They're 17 and think they know everything just because they've touched Crystal in the past
<FromGitter>
<watzon> He's been destroyed by several people and is keeping it up. Typical teenager.
ht_ has joined #crystal-lang
<FromGitter>
<wontruefree> I guess you should ask him to write you a proof
<FromGitter>
<wontruefree> see what he comes up with
<FromGitter>
<watzon> Lol I just might
<FromGitter>
<watzon> Oh God, now he's using Process.fork as an argument
<FromGitter>
<Blacksmoke16> thats the best you could do up till that PR
<FromGitter>
<Blacksmoke16> would there be a benefit of forking if each process is also multithreaded? or im assuming one process with MT is enough to not jam the CPU?
<FromGitter>
<watzon> > That's what I said, yet, if you run an amount of processes equivalent to the amount of CPU threads, and schedule yourself, you can archive better performance than using your fancy ass threading libraries
<FromGitter>
<watzon> Omg tell me I'm having a nightmare lol
<FromGitter>
<j8r> @dscottboggs_gitlab you better avoid recursive aliases
<FromGitter>
<dscottboggs_gitlab> because they're going away? yeah... Don't know how else I would represent that though.
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter>
<wontruefree> Thanks I am reading these
<FromGitter>
<wontruefree> hopefully this will make it all make more sense
<FromGitter>
<bew> @j8r really? No trace when static linking? You know why?
<FromGitter>
<galvertez> did the `finished` macro change recently? I used to be able to use it and enforce some behavior at the end of class inheritance
<FromGitter>
<galvertez> but it's not working in 0.30.0 - `@type` is always the parent now
<FromGitter>
<Blacksmoke16> got some example code?
<FromGitter>
<galvertez> no I figured out what I was doing wrong
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<galvertez> before I was defining the finished macro inside the inherited macro
<FromGitter>
<galvertez> it works now 😁
<FromGitter>
<Blacksmoke16> cool
<FromGitter>
<j8r> @bew it's a bug, it's already known by core members. Don't know personally
<FromGitter>
<Blacksmoke16> you cant share values between macros outside of constants or annotations
alex`` has quit [Ping timeout: 245 seconds]
glassofethanol has joined #crystal-lang
<glassofethanol>
Good afternoon
<FromGitter>
<ikaru5> so no way to achieve this? ⏎ Maybe Im taking the wrong approach... Are you familiar with the ruby gem trailblazer? ⏎ There are "Operations" which provides a "step" macro. ⏎ So you define your Oparation class with a lot of methods and in the top you use `step :method_name` to define the execution order. Im very used to it and trying to build something like that... :) [
<FromGitter>
<ikaru5> its not bad if its not possible. ;) Still huge thanks for answering me!
<FromGitter>
<Blacksmoke16> i would have to know more
<FromGitter>
<Blacksmoke16> like are these methods specific to a class or an instance of a class?
return0e has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> if they are specific to a class you could easily have some class var array of some type
<FromGitter>
<Blacksmoke16> with a macro called `step` that just adds that method to the array
<FromGitter>
<Blacksmoke16> where the macro handles finding the right method, and pushes it to the array
glassofethanol has left #crystal-lang [#crystal-lang]
return0e has joined #crystal-lang
<FromGitter>
<ikaru5> this is exactly the way i managed it to do :D with a classvar array. ⏎ and it would be enough if the methods would be class methods, but they should be instance methods. ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5d60431968406739f96f65ef]
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<FromGitter>
<Blacksmoke16> what executes these methods?
<FromGitter>
<Blacksmoke16> something in `Operation`?
<FromGitter>
<ikaru5> yes, i simply use a "run()" method
<FromGitter>
<Blacksmoke16> could prob get fancy with annotations
<FromGitter>
<Blacksmoke16> er
<FromGitter>
<Blacksmoke16> what if you define like an `add` method on `Operation`
<FromGitter>
<Blacksmoke16> set that as an ivar to empty array
<FromGitter>
<Blacksmoke16> then have step do like
<FromGitter>
<Blacksmoke16> first off its not a triangle
<FromGitter>
<Blacksmoke16> disappointed
<FromGitter>
<ikaru5> Wow! Thanks you! :O this should work! but i need to learn more about annotations first^^ im still very new to crystal
<rkeene>
Blacksmoke16, It's conceptually a triangle, 3 lines -- just not visually :-D
<FromGitter>
<Blacksmoke16> @ikaru5 does it matter the order each method is executed in?
<FromGitter>
<Blacksmoke16> er, ill leave you to play with that, im quite knowledgeable on annotations/macros if you come across something else you need it to do
<FromGitter>
<ikaru5> okay, thanks again. ^^ ⏎ i wondor why nobody did something like that already... trailblazer made a big impact in the ruby world. it seems like crystal got not enough attention in the past year :(
<FromGitter>
<Blacksmoke16> iirc someone mentioned it before
<FromGitter>
<Blacksmoke16> (might have been you tho, i dont remember who it was)
<FromGitter>
<ikaru5> :'D possible
<FromGitter>
<ikaru5> @Blacksmoke16 thanks to your example i finally got it working even without the annotations :]
<FromGitter>
<Blacksmoke16> nice!
<FromGitter>
<dscottboggs_gitlab> why doesn't this work?
<FromGitter>
<Blacksmoke16> i did notice a but where you cant call super if the parent doesnt have any args but the child does
<FromGitter>
<Blacksmoke16> without doing like `*args` on the parent
<FromGitter>
<dscottboggs_gitlab> I still don't get why the macro variable `methods` isnt' defined...
<FromGitter>
<dscottboggs_gitlab> oh I can just expand and do it at runtime dug
<FromGitter>
<Blacksmoke16> 👍
rohitpaulk has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> ok so Idk if this can even work but it really seems like there should be a way to get this to work in crystal. like this is one of the basic elements of a DSL. https://play.crystal-lang.org/#/r/7g1k
<FromGitter>
<sam0x17> anyone know a good *current* source of crystal language stickers? all the stickermule links seem to be broken
mps_ has left #crystal-lang [#crystal-lang]
mps has joined #crystal-lang
<FromGitter>
<watzon> So @dscottboggs_gitlab, you can try something like this. Maybe this will at least help you see what is going wrong.
<FromGitter>
<watzon> @sam0x17 I don't, but if you find one please post it here. I'd like a few.
<FromGitter>
<dscottboggs_gitlab> oh jeeze that's not what I was going for lol
<FromGitter>
<dscottboggs_gitlab> but you can't set values on a `@instance` variable from in a macro........
<FromGitter>
<watzon> Lol I have no clue what you were going for then 😂 just figured I'd try and make it compile
<FromGitter>
<watzon> No unfortunately not, you either have to use a class var or a constant
<FromGitter>
<dscottboggs_gitlab> I know that feel bro 😀
<FromGitter>
<dscottboggs_gitlab> > No unfortunately not, you either have to use a class var or a constant
<FromGitter>
<watzon> Oh btw, going way back to our conversation about NaCl and your libsodium library: if you want to merge what I have into your library I wouldn't be at all opposed. It would make sense to have one good library that completely implements libsodium instead of multiple.
<FromGitter>
<watzon> I got busy and haven't been able to work on it
rohitpaulk has quit [Ping timeout: 258 seconds]
duane has quit [Ping timeout: 245 seconds]
<FromGitter>
<dscottboggs_gitlab> shit, did I bind libsodium and totally forget?
<FromGitter>
<watzon> Maybe it was someone else lol
<FromGitter>
<watzon> I'll have to go look at my issues for NaCl 😂
<FromGitter>
<watzon> Duh, it wasn't you 😂 I'm just stupid
<FromGitter>
<dscottboggs_gitlab> 65 million trees? that's a lot
<FromGitter>
<watzon> Yep! And the Amazon is going to need all the help it can get haha
<FromGitter>
<watzon> I like their premise
<FromGitter>
<dscottboggs_gitlab> for sure
<FromGitter>
<watzon> 80% of their profits go to planting trees
<FromGitter>
<watzon> And it's not a bad search engine
<FromGitter>
<dscottboggs_gitlab> wish their url was a little more memorable....
<FromGitter>
<watzon> I just remember the *eco* part because they're planting trees, then the rest comes to me haha
<FromGitter>
<watzon> I just learned about them yesterday
<FromGitter>
<dscottboggs_gitlab> chopping up a part of one of their artcles: ⏎ ⏎ > At Ecosia... we collect data and do statistical analysis to understand user behavior and trends, how people use our services, and to monitor, troubleshoot, and improve Ecosia. For this we use a self-hosted, secure and encrypted in-house analytics system. This allows us to gather data about how our users interact with Ecosia products in a secure
<FromGitter>
<dscottboggs_gitlab> oh shit I know go *and* python!
<FromGitter>
<watzon> Good thing I like what they're doing, because I'm having a moral quandry
<FromGitter>
<dscottboggs_gitlab> I don't particularly *like* writing either, but like... I realize crystal isn't that marketable and I'm not experienced enough at C++ or Rust for work.
<FromGitter>
<watzon> Yeah Crystal needs to hit v1 already so companies won't be so afraid to use it. I am lucky to be using it at my job,
<FromGitter>
<watzon> Speaking of Lucky, I want a Lucky Framework sticker too
<FromGitter>
<Blacksmoke16> > but you can't set values on a `@instance` variable from in a macro........ ⏎ ⏎ right, why should you be able to?
<FromGitter>
<Blacksmoke16> you can but you have to be within the scope of an object
<FromGitter>
<Blacksmoke16> you obs cant do it just anywhere in the class body
<FromGitter>
<dscottboggs_gitlab> > Yeah Crystal needs to hit v1 already ⏎ ⏎ I agree. I think they (we?) should focus on API stabilization after #8112 is merged, and drop the requirement for windows support for 1.0. With WSL2 there's no reason why a corporate windows shop would use crystal in WSL.
<FromGitter>
<dscottboggs_gitlab> what's the third one?
<FromGitter>
<sam0x17> alpine
<FromGitter>
<sam0x17> linux
<FromGitter>
<watzon> I need Crystal, Ruby, Arch, Rust, and Lucky Framework to start with
<FromGitter>
<watzon> The only one missing is Lucky
<FromGitter>
<sam0x17> lucky you'll probably end up having to order from a custom site and get like 50 of them minimum purchase size lol
<FromGitter>
<dscottboggs_gitlab> at that rate just go buy some sticker paper and print it out yourselrf
<FromGitter>
<watzon> I could probably just message Programming Swag on redbubble and get them to add it
<FromGitter>
<Brandongoodman615> Hey Hey guys, Ruby noob trying to play around with Crystal. Did a Ruby bootcamp and less than a year experience. So apologizing ahead of time for the questions lol
<FromGitter>
<watzon> Woah that's some serious blur
<FromGitter>
<Blacksmoke16> o/
<FromGitter>
<watzon> @Brandongoodman615 no problem, welcome to the community
<FromGitter>
<Brandongoodman615> thanks!
<FromGitter>
<Brandongoodman615> planning on trying to write some noob tutorials like i used in my Ruby bootcamp.
<FromGitter>
<watzon> More learning resources are always good. I suggest using dev.to, as a lot of us do.
<FromGitter>
<Brandongoodman615> I got my first app made and setup a github repo
<FromGitter>
<watzon> Also if you have bigger questions that aren't a good fit for chat you can always ask on https://forum.crystal-lang.org
<FromGitter>
<watzon> We all like to help each other out wherever though
<FromGitter>
<watzon> It's a good community
<FromGitter>
<Brandongoodman615> on mac mojave and struggling to get icr working, was linked here by Jeremy Woertink when submitting an issue to the github
<FromGitter>
<watzon> What's failing? Does it seem to be an LLVM issue? I know macOS tends to have issues with LLVM.
<FromGitter>
<Brandongoodman615> getting an -lssl error and I have open ssl installed and I tried reinstalling
<FromGitter>
<Brandongoodman615> I got all the steps done and the build and install both fail
<FromGitter>
<watzon> Ahh yeah, mac tends to have issues there too
<FromGitter>
<dscottboggs_gitlab> TBH crystal isn't a very repl-friendly language, you're better off using the playground. But I've never gotten the playground working on macos either. Not that I've tried. I just noted that it didn't work and SSH'd into a linux box to ru it.
<FromGitter>
<watzon> Yeah mac makes you work for things haha
<FromGitter>
<watzon> The issue @Blacksmoke16 linked to should help though
<FromGitter>
<Brandongoodman615> I think I tried that one from a search, let me try again
<FromGitter>
<Brandongoodman615> mac has some trouble but try installing ruby on windows lol
<FromGitter>
<dscottboggs_gitlab> @Brandongoodman615 do you have docker?
<FromGitter>
<Brandongoodman615> not sure, so assuming no
<FromGitter>
<watzon> Yeah on Windows you just need to use WSL
<FromGitter>
<watzon> It solves most everything
<FromGitter>
<watzon> Not good for anything graphical unfortunately
<FromGitter>
<dscottboggs_gitlab> > try installing ruby on windows lol ⏎ ⏎ I haven't used windows in years, but I can imagine...
<FromGitter>
<Brandongoodman615> `zsh: command not found: xport` when I try to run that first command
<FromGitter>
<watzon> You're missing an `e`
<FromGitter>
<watzon> `export`
<FromGitter>
<Brandongoodman615> ok building again
<FromGitter>
<watzon> This is killing me right now
<FromGitter>
<watzon> Fuck math
sorcus has quit [Ping timeout: 264 seconds]
<FromGitter>
<dscottboggs_gitlab> I keep meaning to get around to learning ML and never getting to it
<FromGitter>
<watzon> It's a pain in the ass
<FromGitter>
<watzon> Really cool
<FromGitter>
<watzon> But a serious pain
<FromGitter>
<dscottboggs_gitlab> Oh yeah
<FromGitter>
<dscottboggs_gitlab> but the point is to only be a pain in the ass once
<FromGitter>
<watzon> True
<FromGitter>
<dscottboggs_gitlab> then nobody else has to have that pain
<FromGitter>
<watzon> This project has been super difficult. There's just something wrong with my math that's throwing everything off.
sorcus has joined #crystal-lang
<FromGitter>
<watzon> I mean, at least I'm getting paid to work on it
<FromGitter>
<watzon> But I'm gonna be bald before I finish
<FromGitter>
<dscottboggs_gitlab> haha I don't think it'll be that long
<FromGitter>
<dscottboggs_gitlab> althoug for mme it didnt't take long....
<FromGitter>
<watzon> I mean from pulling out my hair 😂
<FromGitter>
<dscottboggs_gitlab> oh haha
<FromGitter>
<sam0x17> @dscottboggs_gitlab ICR is going to be frustrating because what it's doing under the hood is basically just re-run everything you have entered so far each time you hit enter
<FromGitter>
<sam0x17> crystal doesn't have a real (or good fake) repel yet
<FromGitter>
<dscottboggs_gitlab> yeah, I don't get how it would make any sense to have a crystal repl
<FromGitter>
<sam0x17> the closest thing convenience wise is the `exec` feature in amber i.e. `amber exec 'User.where(name: "sam")'`
<FromGitter>
<sam0x17> but that's specific to amber
<FromGitter>
<sam0x17> rust has a crate that offers a more legit repl, because they did some stuff with the compiler that makes it easy to do whatever compiler trickery makes that happen , so theoretically it could happen with crystal someday