5 ms·
Sometimes I forget how insane Perl was before `use strict;` became commonplace.
by qalmakka 5y ago
Sometimes I forget how insane Perl was before `use strict;` became commonplace.
- forgotmypw17 5y agouse strict; has basically eliminated typos or variable-related errors for me. combined with -T, it's given me a lot of peace of mind, which I miss when using PHP. I'm seriously contemplating writing my own SetConst and GetConst functions. (Lately I've been finding a lot of sense in immutable variables.)
- hpcjoe 5y agoFor Perl use const name => value; Though ... I'm not sure why you'd need a "set" constant, as constants should be immutable, and set once ...
- forgotmypw17 5y agoWell, perhaps I should've said SetImmutableVariable? Are consts not allowed to be set at runtime?
- throwanem 5y agoIt sounds like the confusion might be in declaration vs. initialization, which for language-supported consts of course have to happen at the same time. Retrofitting the concept into a language without native support for immutable bindings, you'd of course need some kind of setter on whatever object or similar you're using to encapsulate the binding and ensure it never does actually change.
- forgotmypw17 5y agoI'm combining my lament about lack of "you are using a variable you didn't declare yet" error in PHP and my newly arrived at understanding of the benefits of immutable variables, and then adding to the confusion by using the "constant/const" term, which typically means "set at compile time"
- throwanem 5y agoIn languages with a compilation step, this is true but a side effect. Really, what "const" denotes is an association between a name and a value (ie a binding, in this case an assignment, although there are other kinds of binding such as naming positional arguments in a function signature) which has to be performed when the name is declared, and which cannot be changed once made. (Hence for example in Javascript why properties of an unsealed object can still be modified even via a const binding - what's immutable isn't the value, but the association of that value with the const-declared name.)
- darrenf 5y agoNitpick: use constant name => value; Albeit `Const::Fast` might be considered preferable for several reasons (deeply readonly structures, variables which you can interpolate rather than barewords, etc).
- hpcjoe 5y agoAgreed. I tend to use syntactic sugar like use constant true => (1==1); use constant false=> (1==0); in many of my codes. It lets me use them as barewords, and makes the logic it appears in, saner. But this is a style/taste thing.
- benlivengood 5y ago> combined with -T, it's given me a lot of peace of mind, which I miss when using PHP. Try Hack? It's not too bad and the typing can be added piecemeal.
- qalmakka 5y agoThe main issue I have with Hack is that it is a big PITA to install. Like, there's no HHVM in ArchLinux repositories (or in no other distro's repositories either), and building it is super messy. That's also why I think almost nobody is using Swift on Linux. Nobody is going to bother with your language when it's full out there of solutions as good as yours that people can install in one second.
- jschwartzi 5y agouse English; is handy for making the special global variables something you can actually google search.
- bmn__ 5y agoGoogle improved their negligence in 2019. https://encrypted.google.com/search?q=%24_ https://encrypted.google.com/search?q=%24_