qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Ross (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Qpid > Language support for unambiguous text string and byte array types
Date Wed, 21 Aug 2013 15:11:01 GMT
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/21/_/styles/combined.css?spaceKey=qpid&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/qpid/Language+support+for+unambiguous+text+string+and+byte+array+types">Language
support for unambiguous text string and byte array types</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~justi9">Justin
    <div class="notificationGreySide">
         <div class='table-wrap'>
<table class='confluenceTable'><tbody>
<th class='confluenceTh'> Language     </th>
<th class='confluenceTh'> Overloaded string/bytes type </th>
<th class='confluenceTh'> Unambiguous array-of-bytes type </th>
<th class='confluenceTh'> Unambiguous textual-string type </th>
<td class='confluenceTd'>  C++ (1)      </td>
<td class='confluenceTd'>  std::string                  </td>
<td class='confluenceTd'>  std::vector&lt;byte&gt;               </td>
<td class='confluenceTd'>  &#8211; (2)                          </td>
<td class='confluenceTd'>  Java         </td>
<td class='confluenceTd'>  &#8211;                           </td>
<td class='confluenceTd'>  byte[]                          </td>
<td class='confluenceTd'>  String                          </td>
<td class='confluenceTd'>  Perl (3)     </td>
<td class='confluenceTd'>  SCALAR                       </td>
<td class='confluenceTd'>  &#8211;                              </td>
<td class='confluenceTd'>  &#8211;                              </td>
<td class='confluenceTd'>  Python 2     </td>
<td class='confluenceTd'>  str                          </td>
<td class='confluenceTd'>  bytearray (4)                   </td>
<td class='confluenceTd'>  unicode                         </td>
<td class='confluenceTd'>  Python 3     </td>
<td class='confluenceTd'>  &#8211;                           </td>
<td class='confluenceTd'>  bytes, bytearray                </td>
<td class='confluenceTd'>  str                             </td>
<td class='confluenceTd'>  Ruby 1.8     </td>
<td class='confluenceTd'>  String                       </td>
<td class='confluenceTd'>  Array                           </td>
<td class='confluenceTd'>  &#8211; (5)                          </td>
<td class='confluenceTd'>  Ruby 1.9 (6) </td>
<td class='confluenceTd'>  &#8211;                           </td>
<td class='confluenceTd'>  Array                           </td>
<td class='confluenceTd'>  String                          </td>

<p>(1) Since we use a box type, Variant, in C++, any difficulty interpreting strings
is easily handled by qualifying the value container.  It doesn't seem like too much of a stretch
to me to also take this approach with bindings for languages that don't offer disambiguated

<p>(2) C++ 11 doesn't seem to have a dedicated type for unicode.  It has wide characters
(not the same thing), and it has literal syntax for unicode strings.  These resolve, however,
to arrays of char, char16_t, or char32_t, so there's not type signal we can easily use to
figure out the developer's intention.</p>

<p>(3) I know too little about perl to say what's going on here.  Scalar::Util reftype
seems to offer a way to get more type info.  Perl has an array type, but its use for byte
arrays doesn't appear to be recommended.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
[jross@localhost ~]$ perl -e 'use Scalar::Util qw(reftype); my $foo = "hello"; print reftype(\$foo)
. "\n"'
[jross@localhost ~]$ perl -e 'use Scalar::Util qw(reftype); my $foo = "hello"; print reftype([])
. "\n"'

<p>(4) Python 2's 'bytes' type is simply an alias for str, so we can't use it to disambiguate.
 Python &gt;= 2.6 does, however, have bytearray, which I think would serve well enough.</p>

<p>(5) Ruby &lt;= 1.8 doesn't have string explicit encodings, and I can't tell what
the default is.</p>

<p>(6) Ruby &gt;= 1.9 seems to offer everything we need.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: ruby; gutter: false" style="font-size:12px; font-family:
=&gt; ["\u0001\u0001\u0004\u0000"]
irb(main):015:0&gt; ["\x01\x01\x04\x00"].class
=&gt; Array
irb(main):016:0&gt; x = "holla"
=&gt; "holla"
irb(main):017:0&gt; x.class
=&gt; String
irb(main):018:0&gt; x.encoding
=&gt; #&lt;Encoding:UTF-8&gt;
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=qpid">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
       <a href="https://cwiki.apache.org/confluence/display/qpid/Language+support+for+unambiguous+text+string+and+byte+array+types">View
       <a href="https://cwiki.apache.org/confluence/display/qpid/Language+support+for+unambiguous+text+string+and+byte+array+types?showComments=true&amp;showCommentArea=true#addcomment">Add

To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org

View raw message