Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:23
    caspiano edited #10531
  • Dec 08 23:04
    HertzDevil edited #12623
  • Dec 08 22:57
    Blacksmoke16 edited #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil opened #12828
  • Dec 08 22:34
    straight-shoota edited #12827
  • Dec 08 22:32
    straight-shoota edited #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota opened #12827
  • Dec 08 22:15
    straight-shoota closed #12814
  • Dec 08 17:12
    straight-shoota assigned #12814
  • Dec 08 17:12
    straight-shoota assigned #12813
  • Dec 08 17:12
    straight-shoota assigned #12809
  • Dec 08 17:12
    straight-shoota assigned #12802
  • Dec 08 17:12
    straight-shoota assigned #12797
  • Dec 08 17:12
    straight-shoota assigned #12664
manveru
@manveru:matrix.org
[m]
atm i have for example a server that needs options [a,b,c], and it calls sub-components that require options [b] or [a,c], or [c,d] etc...
each sub-component can be called without the server, in which case you would only need to pass their specific options
so inheritance is a bit weird there...
George Dietrich
@Blacksmoke16
Are these like config values, or like unique types
manveru
@manveru:matrix.org
[m]
mostly configs
should be immutable after initial parsing
George Dietrich
@Blacksmoke16
Have you considered passing in a single config obj versus specific values?
manveru
@manveru:matrix.org
[m]
yeah
but that means i'd need to make the value types either optional, or use totally wrong default values...
George Dietrich
@Blacksmoke16
How so?
manveru
@manveru:matrix.org
[m]
or the user has to pass 50 options even if that command would only need 2 or so
George Dietrich
@Blacksmoke16
How are the values provided?
manveru
@manveru:matrix.org
[m]
either config file, cli flags, url params, default values, or env vars
George Dietrich
@Blacksmoke16
Gotcha
manveru
@manveru:matrix.org
[m]
so that pass-the-full config approach is what i had before, and it sucked :)
when you wanna run db migrations, all you need is the db url, for example
but it will fail for not finding a github token...
George Dietrich
@Blacksmoke16
You could use lazy getters maybe
manveru
@manveru:matrix.org
[m]
at that point it may fail at runtime, which also sucks
George Dietrich
@Blacksmoke16
Only would try to load when called, but would raise if not available
Or really, maybe even getter! Would be sufficient here
manveru
@manveru:matrix.org
[m]
anw, i gotta get some sleep, thanks for the feedback :)
George Dietrich
@Blacksmoke16
o/
postmodern
@postmodern:matrix.org
[m]
@didactic-drunk: should we add Process.fork to crystal-posix? @kevinsjoberg was asking about lack of Process.fork. https://gist.github.com/postmodern/a98e68dff96163b5f234cd9de1c5c75d
2 replies
mfiano
@mjfiano:matrix.org
[m]
I'm trying to solve a visibility issue.
I have private class method self.foo at the module level in one file, and in another file I have a struct defined in the same module. I would like some of the instance methods of the struct to be able to use the private foo method at the module level, but I cannot fully qualify it, and it is not part of the struct so I'm not sure if this is possible. I'm trying to write a file of private helper methods that are used in several other files/structs
mfiano
@mjfiano:matrix.org
[m]
Cancel that. I seemed to have figured out the right incantation to extend the module with private methods according to crystal doc.
From IRC (bridge bot)
@FromIRC
<kevinsjoberg> @postmodern, great idea!
George Dietrich
@Blacksmoke16
@mjfiano:matrix.org could you just make it protected
postmodern
@postmodern:matrix.org
[m]
@didactic-drunk @kevinsjoberg hmm nevermind, looks like Process.fork does exist but is nodoc'ed / part of the private API. https://github.com/crystal-lang/crystal/blob/1.0.0/src/process.cr#L62-L98
mfiano
@mjfiano:matrix.org
[m]
@Blacksmoke16: Maybe, though I'm not sure what that means for module methods...the docs talk about instances. I found a way with private though.
George Dietrich
@Blacksmoke16
mfiano
@mjfiano:matrix.org
[m]
@Blacksmoke16: Interesting. I did something like this: https://play.crystal-lang.org/#/r/bkuh
mfiano
@mjfiano:matrix.org
[m]

Mine probably doesn't do exactly what I expect.

Also, stupid question: I've never seen the double colon syntax for module name as in your example...where is this documented?

George Dietrich
@Blacksmoke16
It's equivalent to creating two modules and nesting them
mfiano
@mjfiano:matrix.org
[m]
Is there a convention when naming methods that side-effect their instance? Some languages use a ! suffix.
Ali Naqvi
@naqvis
yes, Crystal follows same conventions. methods ending with bang represents inline mutation. stdlib have few of them
mfiano
@mjfiano:matrix.org
[m]
Thank you
Ali Naqvi
@naqvis
similarly methods returning bool are usually end with ?
George Dietrich
@Blacksmoke16
! Can also represent methods that raise, while ? Returns nil
But I see more of like .foo and.foo? Versus .foo! And.foo?
mfiano
@mjfiano:matrix.org
[m]
FYI: This convention is very old, derived from Scheme (a Lisp)
mfiano
@mjfiano:matrix.org
[m]
I think I decided on classes over structs. pass-by-value is sort of convoluting my API already.
re: yesterday's discussion
George Dietrich
@Blacksmoke16
:thumbsup: usually the suggested approach is just use classes to start
then can fix bottlenecks as needed, OR if the obj is for immutable and small
mfiano
@mjfiano:matrix.org
[m]
Yeah I chose structs first because this is ultimately going to be for high performance math routines used in math visualization animations
But that was a mistake...for now
George Dietrich
@Blacksmoke16
are you created a lot of objects in a loop or something?
that would prob be noticable diff
@postmodern @kevinsjoberg Absolutely if possible but I don't know how to handle fork.
spawn do
  mutex.synchronize { ... }
end

fork { }
# I think all threads in the child are gone except the current at this point
# 1. What should happen to other fibers?
# 2. If they disappear what happens to their various locks or other states?