Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Quite interesting article Google brought me. Didn’t find any mentions about it here.
What do you think in general? Would you use togethe...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
:warning: Security advisory: Decimal DoS vulnerability
A vulnerability has been published for decimal where very large exponents can cau...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
The problem with that names are
pandprivateparts, because it’s not working as same asdefp(againp-private- here). The point here is to have different naming likeinternaland optionally short it toiinstead ofprivate/p. Sodefmodulepas well asdefprivatecauses too many confusion. To be honestdefprivateis even worse, because it does not refers tomodulein name.massimo
Do you mean that
internalused this way will avoid the confusion?Why not go for private then, it’s used practically in any language, even
Rubyrefers toprivateto declare a private something (a Module in this case) and uses the keywordprivateto declare private methodsMy initial idea was
defprivatemodule, but it’s too long anddef_private_moduleit’s not in style.Maybe it’s a bias I have, but I prefer the emphasis on the
privatepart rather than on themoduleone.Eiji
I said about
internal/iand keepmodulepart which you didn’t.So here is real example:
Because private function (
defp) is working differently than private module in this proposal (defmodulep). Look that private functions can’t be accessed in other modules at all, but there would be a way to access private modules even in other app (look my question about possible hack).massimo
I’m sorry, I’m confused.
Do you mean
defmodulei?Of course private functions work differently than private modules, they serve a different purpose.
The proposal was about
privatemodules, but they are more likefriendinC++.I could have private modules with private functions…
In fact I probably will.
Eiji
Yup as you talking about
private/p→defprivate/defmodulepI’m talking aboutinternal/i(just for example) →defmoduleinternal/defmodulei.Now look that both
defprivate/defmoduleprefers toprivateword as same asdefp, but as you see they work differently, so there can’t beprivate/pword in proposed name. You know other languages, me too, but it does not mean that every newbie would know other languages as well.privatewhich means two different things could be confusing for beginners.massimo
Not really a big difference…
privateorinternalare equivalent to my eyes.I just see that
defmoduleiordefmoduleinternalare longer thendefmoduleand know it’s not a regular module.In this regard, a
pat the end helps more than ani.They are both private.
At a different granularity, but still private (AKA not accessible outside of their scope).
A private function is not accessible outside of the module that declares it, a private module is not accessible outside of <still debating>.
It really means the same thing.
Eiji
It’s not a point to have big difference. The point is to have different naming even if those words are synonyms.
Again and again, helps for you, me and more experienced
Elixirdevelopers. Beginner would be confused whyprivate/pdoes not work as same in both cases. Look that not everyone needs to read this proposition and not everybody even need to understand it.No, they are not private as same as functions are. There are ways to access it outside unlike private functions. Depends on implementation there are few ways to access it.
Look:
privatemeansprivate, but 2 different implementations are 2 different implementations - not the same thing.Imagine that I would write my own
phoenixlibrary. It would be also server, but it would work differently. Naming itphoenixis a big mistake as other developers seeing it could think that it’s fork or something like that. Looking at source they would find that there are 100% different even if both libraries do similar thing. Having same naming for different things is a big mistake as it’s confusing for others. While one team could assume that when we are sayingphoenixwe mean something else other people would see it still as originalphoenix.massimo
Private means
That’s exactly what
privatefunctions and modules are.But that’s not really relevant to the discussion, it’s just a minor implementation detail.
I guess we can agree to disagree on this.
Eiji
Again:
Person A sign agreement for some job offer. Person B does not know if person A receives payment for hours, specific issue or maybe for whole specific project. That’s why person A should say is saying about agreement name instead of saying saying just about agreement. In any case he/she is working, but this does not mean all cases are exactly same. We could guess, we could assume, but nothing good would happen if we would do so.
That’s why people are using names. If you name something properly other people would understand you without taking care of “source”. Well we could name every pet just pet, because basically all pets are pets. Now you can’t filter images only for cats, because there are no cats - there are only pets. We could generalize everything and saying “thing” on everything, but that would be just confusing.
Just take a look at:
Now say again that private in both cases means exactly same.
This topic does not talk about making some modules private. We are talking about guarding some modules to … (show warning, don’t allow access it unless). This is definitely not how private functions are working.
You think that private is private and there is no way to access private modules. In my linked example I show how it’s possible in specific implementation case. That’s why I mean it’s confusing. They are named similarly, but works differently.
privatemeansprivate, but here we have 2 different contexts which makesprivateword more than one meaning and that could be confusing.massimo
I really don’t want to monopolize the discussion.
Most of all, I’m not supporting any solution in particular, once we established private modules are going to be a thing, I’ll gladly accept any syntax for it, Jose and the Elixir team have already proven capable of handling those kind of changes with care.
defmdulei,defmodulep,definternalmodulethey’re all fine to me.But one thing is for certain: private modules are private modules.
They are something hidden from something else, based on some rule.
That’s not gonna change because rules are different for different elements.
Attributes are private too: they are only visible from inside the module and at compile time.
They just don’t have
privatein the name.Private functions are private as well (hence the name).
Think of them as something like
where
visible_tocan be omitted and defaults to[__MODULE__].Private modules are private in the same way, but from an higher level, since we are dealing with cross module visibility and given that modules have only been public until now.
The fact that privateness is not enforced doesn’t make them any less private.
A simple analogy is private offices: nobody is locking himself up inside them, anybody could open the door and see what you’re doing, but they’re private nonetheless, and people usually knock, even though they are not forced to.
No, I don’t.
For now…
I think it’s just a matter of smoothing the transition to a full private module implementation.
Besides, if we are going down that road and implementing them, I would prefer the real deal.
I would also have preferred
privateto be an attribute of the module, even though I’m not a big fan of decorators, this one made sense to me and I think it’s more flexible.I also think using
internalwould cause major headaches when they are going to becomeprivatefor real (I bet it’s not gonna be that far in the future).What’s going to happen to
internal?will it be deprecated? or will it be repurposed?
In the end
privateis just more future proof.And the semantic is preserved.
The risk of confusion is exaggerated in my opinion: novices will read
privateand think of something they should not rely on, just likeprivatefunctions, and that’ll be a good guess, even if they could work around the limitation, while experienced programmers are suppose to know what they are doing.