Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by quietbritishjim on Thursday February 03, 2022 @11:55AM
(#30194924)
Here it seems "INTERNALS" is the "why". If it's not a public API then of course it could change or disappear without warning between releases (including minor releases).
[ Parent
| on HN ]
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by verdverm on Thursday February 03, 2022 @12:01PM
(#30195019)
Go handles this by not allowing 3rd party to import a package path with internal/ in it. Only the current module can
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by MaulingMonkey on Thursday February 03, 2022 @12:14PM
(#30195244)
Ancient vanilla JS can accomplish similar by using wrapper functions.
var React = (function(){
var React = {};
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {};
...code extending/using React etc...
return React;
})();
// accessible: React.whatever
// inaccessible: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
However, there's always caveats where language level access controls don't let you quite express the access restriction you want. Perhaps you want to expose something to other official modules from the same constillation of libraries, for example (meaning you wouldn't be able to use Go's "internal"), without comitting to supporting the semver contract for any other arbitrary user of your API (meaning you might resort to similarly scary names.)
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by udbhavs on Thursday February 03, 2022 @02:02PM
(#30197042)
Private properties in JS classes are syntactic sugar that compile to variable definitions like this in the object's scope
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by ______-_-______ on Thursday February 03, 2022 @01:41PM
(#30196698)
iirc, react-dom (a separate package) needs to access that property as well, which is why it's exposed in the first place
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by drdaeman on Friday February 04, 2022 @01:53PM
(#30211241)
Which is awful, because I've seen a number of FLOSS projects that have perfectly good reusable code in their internal/ subdirectories. And I mean code by no means unique or specific to those projects.
And whoever says something about instability or APIs being subject to change without notice - they're wrong because those are Go git repos and one can always pin to an old tag or even a commit SHA.
If something is unusable (too specific, too fragile, too flaky), no one would use that anyway. A warning is fine and even welcomed, but a block is a slap in the face.
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by mdoms on Thursday February 03, 2022 @01:34PM
(#30196579)
Most sane languages have visibility modifiers. This link refers to Javascript so...
Re:Is it safe to use __secret_internals_do_not_use_or_you_wi...
by verdverm on Thursday February 03, 2022 @01:48PM
(#30196800)
Go did that with casing, so you can tell visibility without lookup or needing to think. The internal/ is a package level restriction, so somewhat orthogonal in that they are for different levels