=pod

=encoding utf8

=head1 NAME

Language::MuldisD::Hierarchical -
Terse Muldis D dialect for daily work

=head1 VERSION

This document is Language::MuldisD::Hierarchical version 0.0.3.

=head1 PREFACE

This document is part of the Muldis D language specification, whose root
document is L<Language::MuldisD>; you should read that root document
before you read this one, which provides subservient details.

=head1 DESCRIPTION

The fundamental way to write Muldis D code is to compose appropriately
typed tuple and/or relation valued expressions which are then stored in the
Muldis D system catalog relvars, whereupon it becomes invokable.  If you
had Muldis D code that was generating other Muldis D code at runtime, such
as you do with string-eval in Perl or you do with "prepared statements" in
SQL, then this process is what that first Muldis D code is actually doing.

If you were taking the bare-bones Muldis D syntax defined in either
L<Language::MuldisD::Dialect::PTMD_Tiny> or
L<Language::MuldisD::Dialect::HDMD_Perl_Tiny>, along with the
system-built-in data types and routines defined in
L<Language::MuldisD::Core>, and using just those instructions to write your
own Muldis D code, you would essentially be working to the metal, and your
code would be very verbose by typical programming conventions.  For now
lets call this writing in the I<Relational Muldis D> dialect, since the
code is composed entirely of tuple|relation definitions.

This document specifies another Muldis D dialect, which for now we will
call the I<Hierarchical Muldis D> dialect.  Moreover, although its
principles could be generalized, for now the details of this document are
specific to the dialect's use in Muldis D as hosted in either Perl 5 or
Perl 6, such as I<HDMD_Perl_Tiny> describes.  So the relational Perl-hosted
dialect will be referred to herein as I<PHMD-R>, and the hierarchical
Perl-hosted dialect will be I<PHMD-H>.

This document is very much an early draft, and for not just contains a bit
of brainstorming in point form.

=head1 HIERARCHICAL MULDIS D DIALECT

PHMD-H code, like PHMD-R code, is fundamentally expressed as a tree of Perl
Array that also comprises some Perl Hash; the tree root is a Perl Array.

Literals of system-defined core scalar types (such as numbers and strings)
are expressed in the same way for both PHMD-H and PHMD-R, as simple Perl
Seq|Array values of 2-4 elements; see I<HDMD_Perl_Tiny> for details.  This
then retains all the meta-data necessary to unambiguously interpret the
scalar values where Perl may be more weakly typed itself.

A PHMD-H expression tree is generally expressed as an actual tree of node
definitions, and those nodes don't need to be named; contrast with PHMD-R
where the nodes are defined in a flat list and are all named.  But PHMD-H
still supports disassembly into multiple named sub-trees, such as when part
of an expression is intended to be used multiple times, as per a
generalization of a named item in a SQL "WITH" clause.  Having actual
N-depth expression trees makes the Muldis D code much more strongly
resemble expression trees in most typical high-level languages, as well as
how humans typically write their math and logic outside of computers.

A PHMD-H expression node does not include deadweight node attributes like
in PHMD-R, because it isn't restricted to making every node of the same
complete tuple data type.  This leads to a drastic reduction in code size.

PHMD-H has a much larger grammar than PHMD-R does.  Speaking in analogy,
its alphabet has 100 characters rather than 10, so you can express all the
possible ideas using a smaller number of characters.  Speaking not in
analogy, PHMD-H has orders of magnitude more PHMD node types than PHMD-R
does; so for example, it has separate C<function|procedure> node types for
declaring a function|procedure, rather than a generic C<Tuple> node type
being used for that; or each kind of value expression (eg, a literal vs
a parameter use vs a function call) each has a different short PHMD node
for it, rather than 1 kind subsuming them all.

PHMD-H permits abbreviations of name-chains for invoking types or routines
et al when said entities are system-defined; generally speaking, any
C<sys.Core.> prefix can be omitted where applicable; often so can the
package name as well.  This does not apply to user-defined entities;
however it is less needed there since there are several levels of
localizing top-level namespaces for user-defined entities already, such as
C<pkg> or C<inn>.  The reason for this selective applicability is because
PHMD-H and PHMD-R code must be unambiguously translatable to the other
dialect in isolation from any knowledge of entities other than built-ins,
such as outside of the DBMS in which they would compile or execute.

PHMD-H provides a bunch of alternate spellings for various system-defined
operators, as aliases; in particular, many symbolic-character aliases.  So
for example, C<=> is provided as an alias for C<is_identical>, and C<< < >>
an alias for C<is_before>, and C<*> as an alias for C<Int.product>, and
so-forth.

PHMD-H provides positional-argument syntax aliases for system-defined
routines, so they can be invoked without argument names.  This does not
apply to user-defined routines as there is no provision in PHMD-R to
declare an order for user-defined routine parameters (save for faking it by
using character string representations of integers for their names).

I<Other details to come, stay tuned!>

=head1 SEE ALSO

Go to L<Language::MuldisD> for the majority of distribution-internal
references, and L<Language::MuldisD::SeeAlso> for the majority of
distribution-external references.

=head1 AUTHOR

Darren Duncan (C<perl@DarrenDuncan.net>)

=head1 LICENSE AND COPYRIGHT

This file is part of the formal specification of the Muldis D language.

Muldis D is Copyright © 2002-2008, Darren Duncan.

See the LICENSE AND COPYRIGHT of L<Language::MuldisD> for details.

=head1 ACKNOWLEDGEMENTS

The ACKNOWLEDGEMENTS in L<Language::MuldisD> apply to this file too.

=cut
