<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>5914</bug_id>
          
          <creation_ts>2008-07-30 12:10:30 +0000</creation_ts>
          <short_desc>[FS]: Normalization of treat as</short_desc>
          <delta_ts>2008-07-31 07:41:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Formal Semantics 1.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Michael Dyck">jmdyck</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>21389</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2008-07-30 12:10:30 +0000</bug_when>
    <thetext>In Bug 5672, it was clarified that treat as can be evaluated lazily.

I&apos;m fairly sure that the input of a typeswitch expression _can&apos;t_ be evaluated lazily, yet treat as is specified in FS to be normalized to a typeswitch expression:

[Expr treat as SequenceType]Expr
==
typeswitch ([ Expr ]Expr)
  case $fs:new as SequenceType return $fs:new
  default $fs:new return fn:error()

Is this normalization rule correct?

With the function:

declare function local:items()
{
  (1, 2, 3, &quot;four&quot;)
};

consider:

(local:items() treat as xs:integer*)[position() lt 4]

and:

(typeswitch ( local:items() )
 case $new as xs:integer* return $new
 default return fn:error())[position() lt 4]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21403</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-07-31 01:47:41 +0000</bug_when>
    <thetext>The dynamic semantics in the FS generally follows an &apos;eager&apos; or &apos;strict&apos; evaluation strategy. (E.g., for a function call, it evaluates all arguments
before invoking the function.) The normalization rule for &apos;treat as&apos; is just another example of that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21406</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2008-07-31 07:41:16 +0000</bug_when>
    <thetext>OK - thanks.

This (I think) is the only normalization rule that an implementation might want to avoid!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>