4 ms·
monthly-salary = daily-rate * working-days Wow. This will make a few people happy who think underlines and camel case are ugly.
by stesch 11y ago
monthly-salary = daily-rate * working-days
Wow. This will make a few people happy who think underlines and camel case are ugly.
- Sharlin 11y agoAdding the missing $ sigils will uglify it quite a bit, though.
- zoffix222 11y agoThey don't need to be "missing". my \working-days = 200; Creates a working-days variable that you can't change.
- awwaiid 11y agoIsn't that sort of a mis-feature that we don't expect to see in code very much? I thought mainly people would be using sigils, and ideally the correct sort of sigil to indicate if it is a single thing, list of things, hash of things, callable thing, etc.
- zoffix222 11y agoI wouldn't call it a misfeature. I think especially in math stuff it would be useful. I've used Δ in my math for Color module and it both has the natural mathematical meaning and must not change after I calculate it: https://github.com/zoffixznet/perl6-Color/blob/master/lib/Color.pm6#L231 https://github.com/zoffixznet/perl6-Color/blob/master/lib/Co... What is a mis-feature is you can't assign-create to these variables when they're part with sigil-bearing variables, so, for example, here I ended up using a sigiled-Δ, which isn't as pretty :) https://github.com/zoffixznet/perl6-Color/blob/master/lib/Color.pm6#L142 https://github.com/zoffixznet/perl6-Color/blob/master/lib/Co...
- raiph 11y agoAiui it's for any time a coder prefers that a noun's name does not emphasize/convey the basic nature of the thing the noun refers to. Fwiw you can assign to such "raw" nouns if you declare that the raw noun you're declaring refers in turn to a rw container. For example, a plain `$` is a container (an anonymous Scalar): my \Δ = my $ = 100; Δ = 200; I came up with the following idiom when pondering snippets on twitter and the fundamental problem that twitter treats strings of the form `@foo` as twitter handles which messes up the formatting of tweets containing `@` sigil'd nouns: my \array =@= 1,2,3; array[2] = 200; say array; displays [1 2 200]
- raiph 11y agoI see it as a natural part of Perl 6's gradual typing approach, ie. a feature, not a mis-feature. It can be mis-applied. It arguably has been mis-applied in this example. But I can also argue it the other way. It depends on whether the intro's goal is to address overly simplistic general criticisms ("sigils are ugly and unnecessary!") or to inculcate mature understanding from the get go.
- kbenson 11y agoThat's a matter of perspective. If adding sigils makes that line's intent and action much more obvious, then the sigils are doing what they are for. Once you accept them for what they are, which is hinting to the programmer, they make more sense. Sigils denote the nouns of the language. They are there for your benefit,not the compiler's.
- epoch1970 11y agoThat's a poor example for the documentation to use. In a case like that, kebab notation leads to visual ambiguity when reading code, especially within an expression performing math operations. It becomes harder, at a glance, to tell if the "-" is the kebab connector or if it's subtraction or negation. Kebab notation makes sense in other contexts, like DOM IDs and CSS class names. It does not make sense in a case like that.