ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
[xsl] RE: Re: xpath2 functions returning ()
by Dimitre Novatchev other posts by this author
Jan 4 2002 9:35PM messages near this date
RE: Higher-order function support as means to reduce the "standard" operators/functions. (Was(Re: [xsl] Re: . in for)) | Re: [xsl] RE: Re: xpath2 functions returning ()
>  > A string is a list (sequence) of characters. The empty string
>  > is an empty such
>  > sequence. It is "no character" but it is still a string
>  > (sequence) -- the empty
>  > string (sequence).
>  
>  If you modeled a string as a sequence of characters, then to have a sequence
>  of strings you would need to allow sequences of sequences; and then you
>  would need to distinguish between an empty sequence and a sequence whose
>  only member was an empty sequence. You can't get rid of the problem that
>  easily!

Shouldn't be a problem, these two sequences are of different type, therefore
cannot/shouldn't be compared. No sense in comparing apples and eggs.

This is no problem in Haskell.

The type of the empty list:

MyExamples>  :t []
[] :: [a]

that is, the type of the empty list is a list of any-typed values having all the
same type.

MyExamples>  :t [[]]
[[]] :: [[a]]

The type of the list having a single element, which is the empty list is:
a list of lists, each of which is of (a single) any-type.

So the the type of the empty sequence is different from the type of the sequence of
sequences that has a single element (even if this single element happens to be the
empty sequence).

As can be seen from the above examples, the HUGS interpreter can automatically
determine the type of these expressions.

It seems to me that what was not the perfect decision was to allow a sequence to
have elements of different type. This is another (additional to using a single type
for sequence and set) unpleasant mix -- this time between lists and something like
tuples. In Haskell lists have undefined zero or positive number of elements of the
same type, while tuples have a pre-defined number of components each with its own
pre-defined type.

It is still unclear to me why the restriction was imposed that a sequence should not
have elements that are sequences. Take into account that every element-node that is
an element of a sequence actually represents a whole tree. Then the statement that a
sequence does not contain elements-sequences -- this statement does not seem to be
perfect -- a sequence can even contain elements that are trees.

Cheers,
Dimitre Novatchev.






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Thread:
Dimitre Novatchev
David Carlisle

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved