Hacker News new | ask | show | jobs
by raiph 2754 days 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):

> 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):

> 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`.

1 comments

> ...the several big or small mistakes I am about to make in the following.

Everything you wrote seems fine to me and you even expounded on what I wrote! However, even if it wasn't, I'd be hardly pressed to come up with a response as clever and resourceful as your responses. For this reason, I quite enjoy reading your comments whenever I come across them on /r/perl6 and /r/programminglanguages.

> Like a lot of P6 stuff this... is both childishly simple but also so general, abstract, and high level... that it can be difficult to explain.

You're totally spot on. The most recent example of my struggle (mainly due to my ignorance of Perl 6 and probably CS concepts too) was the concept of containers and how they interface most assignments in Perl 6. I think the fact that many Perl 6 constructs/concepts, which complex in nature, seem so natural can deceive people who haven't tried it yet. This is because it's easy to overlook (or plainly ignore) how much thought went into both integrating them into the language and make them play nicely together.

---

Thanks for your comments!

> Everything you wrote seems fine to me and you even expounded on what I wrote!

Given that your reply was just the right sort of clear answer that would make up for my original footnote I was especially happy to riff off your answer and get super detailed again. :)

> I'd be hardly pressed to come up with a response as clever and resourceful as your responses.

.oO ( Ever too clever by half )

> The most recent example of my struggle (mainly due to my ignorance of Perl 6 and probably CS concepts too) was the concept of containers and how they interface most assignments in Perl 6.

Yeah. Simple on the outside so noobs can just do their thing. Rich on the inside so gurus can develop new candy and gourmet meals.

Anyhoo, thanks for your reassuring feedback. :)