<FromGitter>
<mwlang> @naqvis and @Blacksmoke16 thank you for helping me out there. Both suggestions improve. I didn't quite get the forall T part. where can I learn more about forall? meanwhile, I came up with this, which I think constrains to the parent class, but not sure? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f63fdb989b38d0921354ad5]
<FromGitter>
<mwlang> well, I also don't want an optional/nillable getter.... not sure how to handle it.
<FromGitter>
<mwlang> I'm just basically trying to set up a lazy way to pluck a PriceFilter from the array of filters iff it's actually accessed (which is going to be relatively rare).
<FromGitter>
<mwlang> i.e. out of three hundred market pairs, I may access this price filter property for 2 or 3 of those markets.
<FromGitter>
<mwlang> same goes for the four or five other types of filters I'm planning to set up like this.
<FromGitter>
<Blacksmoke16> are these market paris distinct types?
<FromGitter>
<Blacksmoke16> or one type used for them all
<FromGitter>
<Blacksmoke16> well to be clear you're not using the getter, so its the same as like `@price_filter : Binance::Responses::PriceFilter?`
<FromGitter>
<Blacksmoke16> well to be more clear, the getter is being redefined
<FromGitter>
<mwlang> I like being clear, changing getter! to @price_filter ...
<FromGitter>
<mwlang> and I added in `{% raise "This only works for Parent types" unless T <= Binance::Responses::ExchangeFilter %}` to guard against unexpected T
<FromGitter>
<Blacksmoke16> is that really needed since you had a `.class` type restriction on it?
<FromGitter>
<mwlang> I wondered. I actually don't think it's needed at all since all implements are living inside a single class.
baweaver has quit [Ping timeout: 240 seconds]
deavmi has quit [Read error: Connection reset by peer]
<FromGitter>
<mwlang> I went back and forth on that...but not sure of the pros and cons of the two choices.
<FromGitter>
<mwlang> the pro here, I reckon is that it convey intent more clearly than "T"
<FromGitter>
<Blacksmoke16> yes, also so you cant pass it random types
<FromGitter>
<mwlang> ```code paste, see link``` ⏎ ⏎ does work. One thing I'm curious about, for the `filter` getter, why can't I shorten the `of Binance::Responses::ExchangeFilter` to just `ExchangeFilter` like I do elsewhere in this class? ⏎ It's all namespaced correctly. [https://gitter.im/crystal-lang/crystal?at=5f6415e3f969413294f1ac53]
<FromGitter>
<mwlang> for clarity: `getter filters : Array(ExchangeFilter) = [] of ExchangeFilter`
<FromGitter>
<Blacksmoke16> is the type required before this one?
<FromGitter>
<Blacksmoke16> yea that imports in ABC order
<FromGitter>
<Blacksmoke16> so if this file comes before the other the other type isnt required yet
<FromGitter>
<mwlang> `ExchangeFilter` comes before `ExchangeSymbol`
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<Blacksmoke16> try adding a require at the top of this file
<FromGitter>
<Blacksmoke16> for it
<FromGitter>
<mwlang> good idea
<FromGitter>
<mwlang> same error!
<FromGitter>
<Blacksmoke16> 😮
<FromGitter>
<mwlang> bug with the `of` scope?
<FromGitter>
<Blacksmoke16> :shrug: i doubt it
<FromGitter>
<Blacksmoke16> try and make a smaller example to see?
alexherbo2 has quit [Ping timeout: 272 seconds]
zorp has quit [Ping timeout: 272 seconds]
<FromGitter>
<Dan-Do> I want to parse module export written by jvs syntax in crystal ⏎ `exports.tpl_home = {"t":"div","a":{"id":"tpl-home"},"i":[...recursive children...]};`
<FromGitter>
<Blacksmoke16> oof gl
<FromGitter>
<Blacksmoke16> well, it just looks like json
<FromGitter>
<Dan-Do> yeap, declarative json
<FromGitter>
<Dan-Do> I can read each line until it reach `;` then it's an object
<FromGitter>
<Dan-Do> but It is not a good way I think
<FromGitter>
<Blacksmoke16> whats the goal of this?
<FromGitter>
<Dan-Do> it's a compiled html template using on web front-end. Now I want to render that template on crystal back-end
<FromGitter>
<Blacksmoke16> wouldnt it be easier to just render the html on the backend versus compile on front end, parse, and recompile?
<FromGitter>
<ibraheemdev> Hey!
<FromGitter>
<Blacksmoke16> hi
<FromGitter>
<Dan-Do> the compiled templates are used on both front and back -end
<FromGitter>
<Blacksmoke16> could you have some intermediate format that both ends could consume to do what they need?
<FromGitter>
<ibraheemdev> At first glance, crystal looks awesome! It combines all the best parts of other languages, ruby's beauty, go channels, C speed, rust macros...
<FromGitter>
<Blacksmoke16> indeed
<FromGitter>
<ibraheemdev> I'm looking to get involved in the language on GitHub, any place I could look to get started?
<FromGitter>
<Blacksmoke16> improving documentation is always welcomed
<FromGitter>
<Blacksmoke16> imo a better solution to handle doc generation would be better time spent
<FromGitter>
<Blacksmoke16> versus improving something that is only used for doc generation
<FromGitter>
<mwlang> like building a yard or rdoc equivalent that Ruby has?
<FromGitter>
<Blacksmoke16> not sure
<FromGitter>
<ibraheemdev> That would also be a really cool project. I'll open an issue in the repo. Most languages have a standard documentation generator...
<FromGitter>
<Blacksmoke16> to be clear there already is one
<FromGitter>
<Blacksmoke16> but its deff not anything super advanced
f1reflyylmao has joined #crystal-lang
<FromGitter>
<Blacksmoke16> more so was saying dont improve the `Markdown` module if you just want better markdown support (outside of doc generation)
f1refly has quit [Ping timeout: 272 seconds]
<FromGitter>
<ibraheemdev> Yes, but wouldn't something like godoc or rdoc be much better? A standardized doc generator and single source for all shards.
<FromGitter>
<Blacksmoke16> Not sure I follow. There is already a standardized doc generator
<FromGitter>
<Blacksmoke16> That's built into the language
<FromGitter>
<ibraheemdev> Sorry, I meant a doc generator that supports more than just markdown, since right now its pretty limited.
<FromGitter>
<Blacksmoke16> Current one also outputs json that can be consumed for more complex stuff
<FromGitter>
<ibraheemdev> Ok, thanks for you help. Ill look into this more
<FromGitter>
<Blacksmoke16> Majority of the time the current implementation is sufficient
<FromGitter>
<ibraheemdev> Yeah, i guesa this really isnt a priority
<jhass>
that's the second half of my first suggestion, yes
<FromGitter>
<extremety1989> i do not want use recursive
<FromGitter>
<vsmilesv> Hello, a complete newbie here, trying to connect some crystal code to a PG database, but cannot figure how to resolve the 'Error: already initialized constant DB::TYPES'. I followed all the crystal docs instructions on the crystal-db usage and the relevant APIs but am not sure what I'm doing wrong... Any help greatly appreciated.... Thanks ⏎ ⏎ '''
<jhass>
doesn't beat iterative, but here's tail recursive and it's in the same ballpark at least: https://p.jhass.eu/8x.txt
<FromGitter>
<naqvis> yeah, problem with first recursive is that it calculates values twice e.g for fib(20), it need to calculate f(19) and f(18), then f(19), it need to calculate f(18) and f(17) first, and so on.
<jhass>
yeah, that's the main diff
<jhass>
haha, I realized I don't need the second return
<jhass>
and that made LLVM happy enough to just precompute it: fib3 761.27M ( 1.31ns) (± 5.04%) 0.0B/op fastest
<FromGitter>
<naqvis> wow
<jhass>
tricking it out of that (n = 3; fibX(n + 42)) brings it closer together for me after dropping the second return, guess LLVM can optimize it better then
<FromGitter>
<naqvis> using your 2 liner fib3 implementation
<jhass>
that's just precomputing it all :D
<jhass>
same for fib4 there
<FromGitter>
<naqvis> :P
ryanprior has joined #crystal-lang
ryanprior has quit [Remote host closed the connection]
hamoko[m] has joined #crystal-lang
return0e[m] has joined #crystal-lang
psydroid has joined #crystal-lang
ryanprior has joined #crystal-lang
zorp has joined #crystal-lang
alexherbo2 has joined #crystal-lang
hamoko[m] has quit [Quit: Idle for 30+ days]
ua has quit [Remote host closed the connection]
<FromGitter>
<Dan-Do> > Hello, a complete newbie here, trying to connect some crystal code to a PG database, but cannot figure how to resolve the 'Error: already initialized constant DB::TYPES'. I followed all the crystal docs instructions on the crystal-db usage and the relevant APIs but am not sure what I'm doing wrong... Any help greatly appreciated.... Thanks ⏎ > ⏎ > ''' ⏎ > ⏎ ...
<FromGitter>
<Dan-Do> Then add some statements there to debug what happened. That's a great thing of open source world 😏
ua has joined #crystal-lang
<FromGitter>
<riffraff169> re what the other guy said, im looking at contributing too...been looking through tickets to see where i could
<FromGitter>
<vsmilesv> > Then add some statements (my favorite one is `pp!`) there to debug what happened. That's a great thing of open source world 😏 ⏎ ⏎ ...will have a go.. thanks for suggestions!
<FromGitter>
<Blacksmoke16> pretty sure thats a compile time error so idt `pp!` would help
<FromGitter>
<Blacksmoke16> can you share some code?
<FromGitter>
<vsmilesv> > pretty sure thats a compile time error so idt `pp!` would help ⏎ ⏎ I posted the same post on the crystal-db channel with the code (sorry, should have communicated this better)... got some success as suggested there, but am now getting connection denied to the PG...
<FromGitter>
<Blacksmoke16> connection denied, sure your username/password is correct? is the db running etc
<FromGitter>
<vsmilesv> Just tried your suggestion and got - ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I am connected to the PG container and I can browse through the data - I see the relevant tables and databases - I am connected... Is there a specific parameter withing the Crystal code to fill the relevant un/pass? [https://gitter.im/crystal-lang/crystal?at=5f64b0baea62d70e651d8a35]
<FromGitter>
<Dan-Do> Did you connect to the db successfully using other tool? Try to disable firewall?
<FromGitter>
<Blacksmoke16> try including username/pass in the connection string
<FromGitter>
<Dan-Do> On Fedora, I am using: `sudo systemctl stop firewalld`
<FromGitter>
<vsmilesv> I am on MACOS running Docker Desktop with the PG container exposed on the port 5432 - both the PG and the Crystal containers are on the same internal docker network that should allow them to communicate to one another... Not sure if the firewall imposes any restrictions in this case...
<FromGitter>
<vsmilesv> I'll try to include the un/pass string in the connection settings...
<FromGitter>
<Blacksmoke16> like `postgres://user:pass@host:5432/db`
<FromGitter>
<vsmilesv> Just tried this with the un/pass details I used to create the PG container - no success just yet unfortunately...
alexherbo2 has quit [Ping timeout: 264 seconds]
f1reflyylmao has quit [Quit: bye fags]
f1refly has joined #crystal-lang
<FromGitter>
<Blacksmoke16> oh wait you're using docker?
<FromGitter>
<Blacksmoke16> if you're using docker compose, try making the `host` the name of the server
<FromGitter>
<j8r> > The 20% Project is an initiative where company employees are allocated twenty-percent of their paid work time to pursue personal projects. [...] Technology company Google is credited for popularising the 20% concept
<FromGitter>
<j8r> indeed could be outside this, then why will it be in the google org then?
<FromGitter>
<ibraheemdev> @j8r > "I’ve got to tell you the dirty little secret of Google’s 20% time. It’s really 120% time." - Marissa Mayer
<FromGitter>
<wyhaines> One can do a lot with a modest amount of Crystal code. I have a project that is *almost* MVP for production, and not counting the React font end, the Crystal bits are a little under 6000 lines right now. Once spec coverage is up to snuff, and the remaining MPV features are probably going to add a few thousand more lines.
<oprypin>
@j8r: the important part about the 20% project is that it's not related to your main work responsibilities. but even then usually such projects are initiatives to help the company overall in other ways
<oprypin>
[20:37:54] <8e55e9@j8r> indeed could be outside this, then why will it be in the google org then?
<oprypin>
maybe they don't feel strongly enough to insist to put their name on it. in favor of getting free publicity?
<FromGitter>
<j8r> yeah, could be...
<FromGitter>
<j8r> Anyway, it doesn't say much at the end to have this project there, compared to Yahoo Japan that actually use it "officially": https://github.com/yahoojapan
<FromGitter>
<j8r> If other guys use also Crystal at Google, it could mean more then
<oprypin>
well i mean yea now there are at least 2 🙃
<FromGitter>
<mwlang> @straight-shoota, this chapter overhaul is a big improvement as I was just on this page trying to understand operators better earlier this week. One thing still don't quite get is what "wrapping" means in the context it's used on this page. i.e. "wrapping positive" or "wrapping addition" for example. Seems like this page could do with expanded treatment / discussion around this topic.
<FromGitter>
<mwlang> I definitely like the cleaned up format the overhaul brings.
<oprypin>
@mwlang: im guessing wrapping is about integer math?
<oprypin>
say if 127 is the maximal int8 then adding 1 to it will wrap around to the other extreme and produce -128
<FromGitter>
<Blacksmoke16> Yea, otherwise it raises an overflow error
<FromGitter>
<mwlang> @oprypin Ah! I never would've guessed that, but its as good of a guess as any.
<FromGitter>
<j8r> oprypin ho right, you're a Googler - looking forward a Crystal project in the google org haha :P. You moved from Sweden to Germany?
<oprypin>
@j8r: yes
<oprypin>
and well, i do feel strongly about publishing under my own name :p
<oprypin>
at one point i wanted to port this one https://github.com/google/starlark-go - maybe it'd do well in the org. but yea not so interested now
<FromGitter>
<j8r> What do you do/code at Google?
<oprypin>
i program in c++ currently. that's about all i should disclose :p
<FromGitter>
<j8r> I was expecting the non-disclosure, I tried at least
<FromGitter>
<j8r> What do you think about Fuchsia OS?
<oprypin>
i don't think about it 🤔
<FromGitter>
<j8r> a non-thing for now? True, not released yet, kind of pre-alpha state
<FromGitter>
<j8r> This big corps like Google are so huge that each hand can do different things without ever knowing what the other do.