5 ms·
> The examples vs Haskell are not helping me understand. Personally I don't think the added verbosity is helping in any way. It doesn't sound to me like you ar
by raiph 8y ago
> The examples vs Haskell are not helping me understand. Personally I don't think the added verbosity is helping in any way.
It doesn't sound to me like you are the right audience for the document you're reading.
Quoting from that page:
> this should not be mistaken for a beginner tutorial or overview of Perl 6; it is intended as a technical reference for Perl 6 learners with a strong Haskell background.
It is not wise to start with a technical reference unless you are already fairly well versed in the basics of the technology you're learning and are motivated to deepen your knowledge of it.
If you are interested in P6 you should start with overview or beginner material. Then, if you have a strong Haskell background, you can refer to the technical reference if and when the overview or beginner material isn't working for you.
(If you are not genuinely motivated to have fun learning P6 then nothing related to P6 will work for you. Are you genuinely motivated to have fun learning P6?)
----
> I'd like to hear opinions on how the use of sigils and the other syntax oddities
If you view childishly simple and natural syntax as "oddities" then your mind is already made up that they are oddities.
So the rest of this comment is intended primarily for other readers and secondarily for you on the off chance that you are able to transcend your mind's confirmation bias against the following constructs actually being simple and natural.
> use of sigils
Many programmers think in terms of three fundamental primitive data types from which all other datatypes are composed:
* single items
* collections of numbered things
* collections of named things
P6 adopts this view and assigns three sigils to these three abstract notions.
This makes it both easier and quicker to both read and write code -- once you've learned how they work. In P5 sigils were onerously complex. In P6 they are childishly simple. So now it's also easy and quick to learn them as well as to use them.[1]
> Int:D, Int:U
In P6, every type that's created using any of its type constructors is a sum type with two sub-types. This includes types defined in the standard language such as Int. The sub-types are named D and U. For example, to refer to Int's D sub-type, use `Int:D`.
This makes it easy and quick to read and write code once you've learned what they are. Fortunately, it's childishly simple to learn what they are.[2]
> given
The `given` keyword means essentially the same as the English word `given`.
This makes it easy and quick to read and write code once you've learned the English meaning of `given`.[3]
> when
The `when` keyword hides a good deal of complexity. But one can hop on Wittgenstein's Ladder easily. Because for the first rung, it just means the same as the meaning of the English word `when` used in the context of something that's `given`.
The keyword `when` makes it easy and quick to read and write code once you've learned the English meaning of `when` in the context of `given` -- and it can then be used in other contexts.[4]
----
[1] 27 second vide clip covers it all: https://www.youtube.com/watch?v=Nq2HkAYbG5o&t=10m&list=PLRuESFRW2Fa77XObvk7-BYVFwobZHdXdK&index=92 https://www.youtube.com/watch?v=Nq2HkAYbG5o&t=10m&list=PLRuE...
[2] They're called "type smilies" for a reason. :D is the definite, happy, valuable type. What's `42`? Simple. Definite. Happy. Valuable. Unlike :D, the other subtype, :U, is undefined, unhappy, not a value. What's `Int`? Is it `42`? No, because that would be defined. Every value/object is either definite/happy or it isn't.
[3] From dictionary.com: given: noun: "an established fact"
[4] From dictionary.com: when: conjunction: "in the event that"
- herrosheep 8y agoWas actually very interesting in your reply until > etc I haven't seen that one. Made me wonder if this was honest or not.
- dang 8y agoIt breaks HN's civility rule to insinuate dishonesty in other users. Please review the site rules at https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html.
- xisukar 8y ago> In P6, every type that's created using any of its type constructors is a sum type with two sub-types. > This includes types defined in the standard language such as Int. The sub-types are named D and U. > For example, to refer to Int's D sub-type, use `Int:D`. Probably your comment hints to this already in which case the following will be redundant but I wanted to mention them more explicitly. This is mainly for people unfamiliar with Perl 6. Using the type smileys(:U, :D) are also ways to specifically match against a type object (`Int`, `Str`, `Rat`, etc.) and an instance object of a type object (-5, 'Hello', 1/5, etc.): Int ~~ Int:U; # True -5 ~~ Int:U; # False -5 ~~ Int:D; # True Int ~~ Int:D; # False There is also the :_ smiley which is used by default whenever the other two aren't specified: Int ~~ Int; # True, same as: Int ~~ Int:_; -5 ~~ Int; # True, same as: -5 ~~ Int:_;
- raiph 8y ago> Probably your comment hints to this already Regardless, I'm glad you've written your comment to clarify. :) I'd be delighted to hear about any of the several big or small mistakes I am about to make in the following. Also an honest opinion about whether the following approach I take boils down to one that is complete gibberish, vaguely interesting but terribly complex, OK but meh, good but a bit abstract, enlightening, or something else. If you do let me know, please clarify whether you mean what you say for just you, or for what you think might be true for others that don't know P6 at all. TIA. ---- Like a lot of P6 stuff this basic aspect of its type system is both childishly simple but also so general, abstract, and high level, and comes at things from such a different angle than pretty much all other languages, that it can be difficult to explain. Another attempt at what I was trying to get at in my second footnote in my GP comment... ---- A P6 type and its two standard sub-types are a simple and fun unification of the universal/existential "quantification" that our inner logician loves and the "article definiteness" distinction recognized by our linguistic side. From https://en.wikipedia.org/wiki/Article_(grammar) https://en.wikipedia.org/wiki/Article_(grammar): > The articles in English grammar are "the" and "a/an" ... In languages that employ articles, every common noun, with some exceptions, is expressed with a certain definiteness, definite or indefinite From https://en.wikipedia.org/wiki/Quantifier_(logic) https://en.wikipedia.org/wiki/Quantifier_(logic): > The two most common quantifiers mean "for all" [Universal] and "there exists" [Existential]. ---- :D denotes a definite thing. It is directly analogous to "the". The value `42` is considered definite. Definiteness implies that a thing actually exists. Its the linguistic analog of existential quantification. Many coders talk about happy/sad path processing. :D is associated with the happy path, perhaps because it has no existential crisis. :D ---- :U is related to Universal quantification. As a type, it is also related to "a". Quoting wikipedia: > An indefinite article indicates that its noun is not a particular one identifiable to the listener. :U corresponds to an indefinite thing, something that's only identifiable as a Universal, not a Definite thing. :U is also associated with Undefined things, even if they are supposed to be undefined. In the context of talk about happy/sad path processing, :U is associated with the Unhappy path, because it can denote a thing that should be definite but isn't. ---- As a value, a type name without a `:D` or `:U` smiley is the same as the type name with a `:U`. As a type, a type name without a smiley is the same as the type name with a `:_`, where the `_` denotes either `D` or `U`. Thus: * `Int`, as a thing in of itself, is the same as an `Int:U`. * `Int`, as a type of thing, denotes either an `Int:U` or an `Int:D`.