on the Curl Web Content Markup Language

on the Curl Web Content Markup and Programming Language from www.curl.com and www.curlap.com

Thursday, December 22, 2011

Dorothy Parker one-liner

As seen at http://rpo.library.utoronto.ca/poem/1554.html aka Representative Poetry ONLINE:

<div class="a"><span class="head"><br<</span></div><div class="a"><span class="numb">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1</span><span class="line">My own dear love, he is strong and bold</span></div>

That is one line of Dorothy Parker's Love Song: readers of books never saw the lead type - but could it have been as ugly, when read in a mirror?

A Curl equivalent in poetry markup might be

{ln 1, My own dear love, he is strong and bold}


Thursday, December 15, 2011

Curl CAEDA Mobile

A preview of the Curl Mobile framework is now available in English at http://caede.curl.com/en/.

CAEDA is an acronym for Curl Application Export Development Environment.

With a few restrictions on Curl features (e.g., no multiple class inheritance in user classes) a Curl application can be exported as HTML5 (+ JavaScript, CSS), thereby no requiring the Curl RTE (Runtime Engine or browser plugin) on mobile devices.

Of course, compared to installing Java for a browser, the Curl RTE is a snap to install on any MAc, Windows or Linux platform, but for Android and iOS systems the problem is more serious.

Curl as the development language offers a terrific environment for debugging and testing web applets. The developer works in one language, not three.

Over the next two weeks I will be working with the CAEDA preview and reporting back at communities.curl.com on my tech blog: Robert's Blog.

Wednesday, December 7, 2011

Curl Mobile Preview

The Curl mobile preview is at http://caede.curl.com/ja/ as Caeda - The Curl Application Export Development Environment.

Caeda is intended to make Curl a one-web-language-fits-all for Android and iOS.

Wednesday, November 23, 2011

Gears Goes Off-Line

The final word on Google Gears:
In March we said goodbye to the Gears browser extension for creating offline web applications and stopped supporting new browsers. On December 1, 2011, Gears-based Gmail and Calendar offline will stop working across all browsers, and later in December Gears will no longer be available for download. This is part of our effort to help incorporate offline capabilities into HTML5, and we’ve made a lot of progress. For example, you can access Gmail, Calendar and Docs offline in Chrome.


Curl continues to off Occasionally-Connected Computing features.

Saturday, November 12, 2011

Hegel Phänomenologie des Geistes without Italics

One edit redefining {i } in the tiny Curl file gives another version of Hegel Die Phänomenologie des Geistes in German without his italics,


See:   


This was done with no change to the huge source text file itself.


And now the e-book loads faster and is less annoying overall.


What changed?


{define-text-format i as italic}


became


{define-text-format i as text}


Of course it was first necessary to have his text in italics wrapped in {i An-Sich} etcetera, but that was simple in practice with a good editor.


The full URL is http://phil.aule-browser.com/phaenomenologie-des-geistes-no-italics.html


and the former with italics is http://phil.aule-browser.com/phaenomenologie-des-geistes.html


Both are at http://phil.aule-browser.com where I have my philosophy texts in Curl web content markup from www.curl.com.





Wednesday, November 9, 2011

Hegels Phänomenologie


Ich habe ein komplettes Hegel Die Phänomenologie des Geistes in deutscher Sprache unter
http://phil.aule-browser.com/phaenomenologie-des-geistes.html hinzugefügt.

Es ist in die Curl Web-Content-Markup Sprache mit Text-Formatten für Philosophische Texte und E-Bücher definiert. Das Betrachten dieser Web-Seite benötigt der Curl RTE-Browser-Plugin von www.curl.com.

Die Seite hat ein BaumStil Inhaltsverzeichnis auf der linken Seite der WebPage und eine Reihe von Links in den Inhalt an der Spitze der Text; Version ohne kursiv wird ein paar Minuten länger dauern.

I have added a complete Hegel Die Phänomenologie des Geistes in German at
http://phil.aule-browser.com/phaenomenologie-des-geistes.html

The book is in Curl web content markup using text-formats defined for philosophy texts and e-books.
The page requires Curl RTE browser plugin from www.curl.com

The TocDocument has a tree table of contents on the left and a set of links in the Inhalt chapter at the top of the text. 

A version with no italics will take a few minutes more (just redefine the text-format in the Curl file without touching the text as marked-up in the Scurl file.  One source - many presentations.)

Curl TIP: the top index in the text display window has {link } expressions to {destination } expressions in the text.  If they are to work, those links MUST be in the .curl Applet file and not in the .scurl file containing the markup of the large text.

Sunday, November 6, 2011

Sunday, October 23, 2011

Curl Starter Kit

I was surprised to find the old Curl 5.0 Starter Kit (CSK) over at curlap.com under developers.curlap.com

The 50MB download had been used extensively by at least one Curl client for commercial applications.

Until there is a more adequate replacement for developers.curl.com this is at least one resource for beginners.

While out-dated, it does contain some working Curl at an easily accessible level.

The first hitch will be that the programmer must set the unzip target folder to being a trusted folder in the Curl Control Panel - which must be running - by clicking on "Add Privleged Directory" and pasting the path or browsing to the folder.

N.B.  To avoid a fatal error, be sure your target install directory exists before starting the Dcurl desktop application which is used for the install.  When install completes, there is no copy option on the pop-up menu - and print TO FILE will cause a fatal lock-up.  No matter - the release notes are in the top folder.

Here is the important bit: Charts has evolved a long ways since this was last touched in 2006.  This is the key bit from the release notes:
A migration directory is included with this release that illustrates how GUI charts do what CSK charts did, and how GUI charts can be extended to accomplish things the CSK charts could not easily do - see the EXAMPLES OF GUI CHARTS DOING WHAT CSK CHARTS DID AND MORE in migration/GuiChartsVsCSKCharts.txt. There is also a document describing how to structure your data as you migrate away from the CSK charts toward the GUI charts - see the NOTES ON PREPARING TO USE THE NEW GUI CHARTS in migration/GuiChartsVsCSKCharts.txt
On the face of it I see no reason to perform the install (even the installer files will be "installed".)  Regardless, you will want to go to CurlInc\CSK5.0\docs-install\CSK
from your Curl Documentation Viewer so as to add the CSK docs: just select that manifest file.

N.B. You will only see those when you have an old Curl 5.0 version applet in development - so you may have to create one using something like {curl 5.0,6.0,7.0,8.0 applet} as your herald.

The latest Curl demos can be founded by following links at developers.curlap.com

Friday, August 5, 2011

Character encodings

I thought that it is useful to have this Curl 7.0 info in one place.  On my Windows PC, the procedure returns over 100 CharEncoding of various types.

The information is in two dumps: one by type from the debugger and one as terminal output (they are separated by a Curl comment below.)

The first dump I have reordered slightly to group the types.

{get-all-character-encodings}  || 103 items in {Array-of CharEncoding}

  type                          name

NoneCharEncoding      "none-specified"
ShiftJISCharEncoding  "shift-jis"
EUCJPCharEncoding  "euc-jp"
UTF8CharEncoding      "utf8"
UTF8CharEncoding       "utf8-with-byte-marker"
UTF16CharEncoding    "ucs2-big-endian"
UTF16CharEncoding    "ucs2-little-endian"
UTF16UnknownEndianCharEncoding   "ucs2-unknown-endian"
SingleByteCharEncoding    "ascii"
SingleByteCharEncoding    "iso-latin-1"
MappedSingleByteCharEncoding   "windows-latin-1"
MappedSingleByteCharEncoding  "iso-latin-2"
MappedSingleByteCharEncoding   "iso-latin-3"
MappedSingleByteCharEncoding  "iso-latin-4"
MappedSingleByteCharEncoding  "iso-cyrillic"
MappedSingleByteCharEncoding   "iso-greek"
MappedSingleByteCharEncoding  "iso-latin-5"
MappedSingleByteCharEncoding  "iso-latin-6"
MappedSingleByteCharEncoding  "iso-latin-7"
MappedSingleByteCharEncoding  "iso-latin-8"
MappedSingleByteCharEncoding  "iso-latin-9"
MappedSingleByteCharEncoding  "windows-latin-2"
MappedSingleByteCharEncoding  "windows-cyrillic"
MappedSingleByteCharEncoding  "windows-greek"
MappedSingleByteCharEncoding  "windows-turkish"
MappedSingleByteCharEncoding  "windows-baltic"
MappedSingleByteCharEncoding  "koi8-r"
MappedSingleByteCharEncoding  "koi8-u"
MappedSingleByteCharEncoding  "dos-cyrillic"
HostEncoding   "win32:21027" 21027
HostEncoding   "win32:52936" 52936
HostEncoding   "win32:50227" 50227
HostEncoding   "iso-8859-11"     874
HostEncoding  "win32:50220" 50220
HostEncoding  "win32:10003" 10003
HostEncoding  "win32:10007" 10007
HostEncoding  "win32:10079" 10079
HostEncoding  "win32:21866" 21866
HostEncoding  "win32:1254"    1254
HostEncoding  "win32:28605" 28605
HostEncoding  "win32:28597" 28597
HostEncoding  "win32:50229" 50229
HostEncoding  "win32:28592" 28592
HostEncoding  "win32:855"       855
HostEncoding  "win32:10000" 10000
HostEncoding  "win32:10008" 10008
HostEncoding  "win32:51949" 51949
HostEncoding  "win32:65000" 65000
HostEncoding  "win32:10082" 10082
HostEncoding  "win32:65001" 65001
HostEncoding  "win32:28603" 28603
HostEncoding  "gb2312"           936
HostEncoding  "win32:1257"    1257
HostEncoding  "win32:860"      860
HostEncoding  "win32:20000" 20000
HostEncoding  "win32:10006" 10006
HostEncoding  "gb2312-80"   20936
HostEncoding  "win32:10017" 10017
HostEncoding  "win32:866"        866
HostEncoding      "gb18030"   54936
HostEncoding      "win32:37"       37
HostEncoding      "win32:1253" 1253
HostEncoding      "win32:10029" 10029
HostEncoding      "win32:20949" 20949
HostEncoding      "win32:1026" 1026
HostEncoding      "win32:20127" 20127
HostEncoding      "johab"            1361
HostEncoding      "win32:28599" 28599
HostEncoding      "euc-kr"           949
HostEncoding      "win32:863"      863
HostEncoding      "win32:20932" 20932
HostEncoding      "win32:1252" 1252
HostEncoding     "win32:737"     737
HostEncoding     "win32:28594" 28594
HostEncoding     "win32:28591" 28591
HostEncoding     "win32:20866" 20866
HostEncoding     "win32:28595" 28595
HostEncoding     "win32:875"        875
HostEncoding     "win32:500"        500
HostEncoding     "win32:20290" 20290
HostEncoding     "win32:50225" 50225
HostEncoding     "win32:10010" 10010
HostEncoding     "win32:50222" 50222
HostEncoding     "win32:20261" 20261
HostEncoding     "win32:1251"   1251
HostEncoding     "win32:861"       861
HostEncoding     "win32:437"      437
HostEncoding     "win32:869"      869
HostEncoding     "windows-1255" 1255
HostEncoding     "win32:10002" 10002
HostEncoding     "win32:10081" 10081
HostEncoding     "windows-1258" 1258
HostEncoding     "win32:857"       857
HostEncoding     "win32:50221" 50221
HostEncoding     "win32:10001" 10001
HostEncoding     "win32:775"      775
HostEncoding     "win32:865"      865
HostEncoding     "win32:932"      932
HostEncoding     "win32:852"      852
HostEncoding     "win32:1250"   1250
HostEncoding     "windows-1256" 1256
HostEncoding     "win32:850"      850
HostEncoding     "big5"              950

|# ------------------------------------------------------------------------ #|

name                       display-name

none-specified         None
ascii                       US ASCII
iso-latin-1                Western European (ISO)
windows-latin-1        Western European (Windows)
utf8                         Unicode (UTF-8)
utf8-with-byte-marker    utf8-with-byte-marker
ucs2-big-endian           Unicode (UTF-16BE)
ucs2-little-endian         Unicode (UTF-16LE)
ucs2-unknown-endian  Unicode (UTF-16)
iso-latin-2       Central European (ISO)
iso-latin-3       Southern European (ISO)
iso-latin-4       Northern European (ISO)
iso-cyrillic      Cyrillic (ISO)
iso-greek       Greek (ISO)
iso-latin-5      Turkish (ISO)
iso-latin-6      Nordic (ISO)
iso-latin-7      Baltic (ISO)
iso-latin-8      Celtic (ISO)
iso-latin-9      Latin 9 (ISO)
windows-latin-2          Central European (Windows)
windows-cyrillic         Cyrillic (Windows)
windows-greek          Greek (Windows)
windows-turkish        Turkish (Windows)
windows-baltic   Baltic (Windows)
koi8-r               Cyrillic (KOI8-R)
koi8-u              Cyrillic (KOI8-U)
dos-cyrillic       Cyrillic (DOS)
shift-jis            Japanese (Shift-JIS)
euc-jp             Japanese (EUC)
win32:21027      21027 (Ext Alpha Lowercase)
win32:52936      52936 (HZ-GB2312 Simplified Chinese)
win32:50227      50227 (ISO-2022 Simplified Chinese)
iso-8859-11       Thai (ISO)
win32:50220      50220 (ISO-2022 Japanese with no halfwidth Katakana)
win32:10003      10003 (MAC - Korean)
win32:10007      10007 (MAC - Cyrillic)
win32:10079      10079 (MAC - Icelandic)
win32:21866      21866 (Ukrainian - KOI8-U)
win32:1254       1254  (ANSI - Turkish)
win32:28605      28605 (ISO 8859-15 Latin 9)
win32:28597      28597 (ISO 8859-7 Greek)
win32:50229      50229 (ISO-2022 Traditional Chinese)
win32:28592      28592 (ISO 8859-2 Central Europe)
win32:855         855   (OEM - Cyrillic)
win32:10000      10000 (MAC - Roman)
win32:10008      10008 (MAC - Simplified Chinese GB 2312)
win32:51949      51949 (EUC-Korean)
win32:65000      65000 (UTF-7)
win32:10082      10082 (MAC - Croatia)
win32:65001      65001 (UTF-8)
win32:28603      win32:28603
gb2312             Chinese Simplified (GB2312)
win32:1257       1257  (ANSI - Baltic)
win32:860         860   (OEM - Portuguese)
win32:20000     20000 (CNS - Taiwan)
win32:10006     10006 (MAC - Greek I)
gb2312-80        Chinese Simplified (GB2312-80)
win32:10017     10017 (MAC - Ukraine)
win32:866        866   (OEM - Russian)
gb18030          Chinese Simplified (GB18030)
win32:37          37    (IBM EBCDIC - U.S./Canada)
win32:1253      1253  (ANSI - Greek)
win32:10029    10029 (MAC - Latin II)
win32:20949     win32:20949
win32:1026      1026  (IBM EBCDIC - Turkish (Latin-5))
win32:20127     20127 (US-ASCII)
johab               Korean (Johab)
win32:28599     28599 (ISO 8859-9 Latin 5)
euc-kr              Korean (EUC)
win32:863        863   (OEM - Canadian French)
win32:20932     20932 (JIS X 0208-1990 & 0212-1990)
win32:1252       1252  (ANSI - Latin I)
win32:737        737   (OEM - Greek 437G)
win32:28594     28594 (ISO 8859-4 Baltic)
win32:28591     28591 (ISO 8859-1 Latin I)
win32:20866     20866 (Russian - KOI8)
win32:28595     28595 (ISO 8859-5 Cyrillic)
win32:875        875   (IBM EBCDIC - Modern Greek)
win32:500        500   (IBM EBCDIC - International)
win32:20290      20290 (IBM EBCDIC - Japanese Katakana Extended)
win32:50225      50225 (ISO-2022 Korean)
win32:10010      10010 (MAC - Romania)
win32:50222      50222 (ISO-2022 Japanese JIS X 0201-1989)
win32:20261      20261 (T.61)
win32:1251       1251  (ANSI - Cyrillic)
win32:861         861   (OEM - Icelandic)
win32:437         437   (OEM - United States)
win32:869         869   (OEM - Modern Greek)
windows-1255     Hebrew (Windows)
win32:10002      10002 (MAC - Traditional Chinese Big5)
win32:10081      10081 (MAC - Turkish)
windows-1258    Vietnamese (Windows)
win32:857         857   (OEM - Turkish)
win32:50221      50221 (ISO-2022 Japanese with halfwidth Katakana)
win32:10001      10001 (MAC - Japanese)
win32:775         775   (OEM - Baltic)
win32:865         865   (OEM - Nordic)
win32:932         932   (ANSI/OEM - Japanese Shift-JIS)
win32:852         852   (OEM - Latin II)
win32:1250       1250  (ANSI - Central Europe)
windows-1256   Arabic (Windows)
win32:850        850   (OEM - Multilingual Latin I)
big5                Chinese Traditional (Big5)
|| -------------------------------------------------------------

Wednesday, August 3, 2011

Curl for creative e-books

With Facebook absorbing Push Pop Press and more interest in Curl from the server-side, should we not be taking Curl seriously as a format for creative e-books?

To get an idea, look at what TiddlySpot.com and TiddlySpace.com have been able to do for TiddlyWiki using Python and PHP.

Curl macros are natural for templates for page layout - and there is all the experience gained from the recent addition of stylesheets to Curl pages - and a new style-designer is coming.

What is missing is e-books that are sync'd to WBT as "smart textbooks" to complement web-based training (and not the fat binder of photocopies, pul-lease!

Saturday, July 30, 2011

Curl.TiddlySpace.com

I have started a collection of "tiddler" notes at http://curl.tiddlyspace.com using their variant of TiddlyWiki, the one page wiki.

On the server-side, these wikis tend to be PHP or Python, but on the client-side they are a tangle of JavaScript and CSS in a single portable HTML file.

So naturally I cannot help but wonder what a TiddlyWiki could offer as a Curl page.  For "plugins" we might use Curl's dynamic package loading.

Many TiddlyWiki implementations are curently hampered on browsers built with WebKit in that the TW page must be accompanied by a tiny Java JAR file to permit updates to the server.

I will try to find a moment to put up a post on a TW using Curl OCC (Occasionally-connected Computing.)

A useful TW is the d-cubed variant for GTD which you can see at my http://aule‑pages.tiddlyspot.com

Friday, July 29, 2011

TDD with the Curl web content language

 
I had started a series introducing Test-driven development over at the former Curl developer blogs. I may revive those posts at lcurlr.tiddlyspace.com.

One thing that may not find a place in those posts is avoiding tight-coupling of tests to class hierarchy.  Curl is a multi-inheritance language with Traits or mixins (abstract classes with some generic methods implemented.)   In the later stages of development, refactoring in the source code should have minimal impact on tests.  That goal will only be achieved if user-defined subclasses are not needlessly referenced in tests.  Behavior, not deep hierarchies, is to be our guide in development – but even such a shallow user-defined hierarchy should be loosely-coupled to our test cases.

The standard way to avoid this in single inheritance languages is to use factory methods in the tests: Curl comes with native factory constructor types. But in Curl there will also be other options particular to multiple-inheritance, parameterized classes and mixins. And with Curl macros, even more inventiveness is possible.

Tests need to wrap complexity - not expose complexity - as much as any other code that we write. Tests must both cast an wide net and yet be loosely-coupled, stable, readable, documented and maintainable.

Professional Curl installations also come with code coverage tools, whose use as can be seen in the new GUI testing framework in the Curl External Library at sourceforge.net . Coverage tools were introduced in the "classic" Curl desktop IDE and are now part of the Curl Eclipse plugin or CDE.

Thursday, July 21, 2011

Curl open-source Sonntag GUI framework

 
Over at communities.curl.com I have a post on the Curl open-source Sonntag framework at sourceforge.net .

Why the name?  Well, it tag's components with the optional name property ... and sonner seems to ring a bell ... [ to get off a bus is an event.]  O-kay, we'll stop that punning for now ...

What is needed is a much more elaborated demo than that currently available.  I will try to find time to work on one. Two small things need doing for the existing demo: move it up to Curl 7.0 from 6.0 and show that Sonntag ties-in seemlessly to Curl automated testing for GUI Visual components.

From where I stand, this little framework is important for what it demonstrates about the strengths of Curl in keeping the complexity of Events for GUI widgets under wraps.

Sonntag achieves that through live-code doc's, Curl macros, mixin's, multiple inheritance and parameterized classes and effective packaging.

Monday, July 4, 2011

Curl 8.0 and mobile roadmap

The SCS Curl page has a link to CodeZine in Japan with a roadmap for Curl 8.0 thru 9.0 over the next two years.

Highlights include Curl Lite for mobile, an Application Integrated Famework and then that AIF for the Cloud, a new Style Designer for GUI skins and much more.

If you have seen or tried Mobl, you will know how very close that language is to Curl in its declarative-style DSL for mobile.  Curl has been missing on mobile platforms and now Curl Lite 1.0 and 2.0 are on the roadmap now.  What Mobl does not have are all the other great strengths of Curl as a language, a framework and a growing set of libraries.

There is even a mention of server-side Curl sometime in the future in the 3 page article.

Sunday, June 26, 2011

Curl page from Ruby CGI

Over at Aule-Browser I have Ruby CGI generating a page with the following:

This web page is Curl web content (no HTML5 or CSS or JavaScript.)


For information about Curl web markup, programming in Curl and Curl open-source: www.Curl.com


Here is the code and markup used:
{curl 7.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{document-style DefaultDocument}
{set-document-properties background={Background.from-string "linen"}, margin=0.75in}
{text This web page is {bold Curl web content} (no HTML5 or CSS or JavaScript.)}
{paragraph

  For information about Curl web markup, programming in Curl and Curl open-source:
  {link target="_blank", href={url "http://www.curl.com"}, www.Curl.com}
}
 \u0000  {br}  || but note that in a Ruby heredoc I must escape my unicode escape
{paragraph Here is the code and markup used:}
{pre
{curl 7.0 applet} ... etc etc ...  }
                                                                                               


but what that does not show is the simplicity of the CGI:
#!/usr/bin/ruby
# curl_01.cgi

puts "Content-Type: text/vnd.curl"
puts

puts "{curl 7.0 applet}",
<<eos
{curl-file-attributes character-encoding = "utf8"}
{applet
    {compiler-directives careful? = true}
}
{document-style DefaultDocument}

{set-document-properties background={Background.from-string "linen"}, margin=0.75in}

{text This web page is {bold Curl web content} (no HTML5 or CSS or JavaScript.)}

{paragraph

  For information about Curl web markup, programming in Curl and Curl open-source:
  {link target="_blank", href={url "http://www.curl.com"}, www.Curl.com}
}
 \\u0000  {br}  || but note that in a Ruby heredoc I must escape my unicode escape

{paragraph
  Here is the code and markup used:}

{pre |"
{curl 7.0 applet}
etc etc
}
eos

Tuesday, June 21, 2011

Curl top-level code and the doc's live code example macro

Curl neophytes are sometimes confused by the use of {value } macros in the examples in the Curl doc's.

I have placed an alternative example style below.

Curl at the top-level is rather like minimalist HTML: if you place a value in a page then the value gets displayed.

But usually a Curl applet is not a {value } expression at the top-level in a .curl file and this adds to unfamiliarity.

The example does include one use of a {value } expression - the macro is used in a {paragraph } text‑proc.

{value } is used in the live code doc's because we are passing our example value into a macro such as {example }.

In my variant example, a {do } expression is used with a top-level global public var instead. The macro {value } is used in {paragraph } as it might be used in a typical applet.

My revision:

The Curl docs on String Files for the scheme curl://some‑text‑resource has a live code {example } using {string-url }

Here is a variant of that example which uses the Curl macro {with-open-streams   do }

The example is not wrapped in a {value } macro as neophytes find this confusing and it is not required for this example at the 'price' of a public global var in the example code.  The text‑proc paragraph preserves our whitespace for our lines as read.

|| Note: we do not need to {set } myinput in this variant of the example.

{def result:StringBuf = {StringBuf}}
{do
    || create a string to be read as a stream
    def mystring:String = "This is some string data I want to read as a stream \nin order to test a macro"

    || Construct a Url under the curl://string directory, using the
    || string we want to read as the filename.
    def myurl:Url = {string-url mystring}

    || Now, read from it as if it were a normal file.
    let myinput:#TextInputStream

    {with-open-streams myinput = {read-open myurl} do

        {until myinput.end-of-stream? do
            {result.concat {myinput.read-one-line}}}

    }
}  

{paragraph text-preserve-whitespace?=true, {value result}}

Wednesday, June 8, 2011

OpenCurl Curl

While I see the expression OpenCurl only twice at http://www.curl.com/, I am seeing it in the readme.txt files of Curl projects at sourceforge.net and have noted the variant OPENCURL at code.google.com/p/zuzu-curl

The failure to protect Curl as a trademark of the M.I.T. spin-off corp has had the sad consequence of confusion with cURL.

The latest Curl library in beta as sourceforge bears the identifier COM.CURL.EXT and not OPENCURL.EXT.

Perhaps when that library goes to a 1.x release we will be closer to Curl 8.0 aka curl9.

Thursday, April 14, 2011

def for constants and the new look of Curl code

Here is what the Curl docs say about the def macro:

def  declares
one or more new constants in the current block of code whose type may be inferred from the type of the value expression used to initialize it. The new constant is implicitly declared to be constant and may not be set to a different value after it has been initialized, but if the constant is a class instance its internal state may change.
This changes the face of curl coding as can be seen in the following snippet from a server HTTP procedure which you can find in the Curl extended examples.  The code is found within a {for } loop expression:

            def (num-bytes-decoded, chars) =
                {decode-characters
                    request.underlying-FastArray,
                    CharEncoding.ascii,
                    in-end = i + 2
                }
            || Now break apart the first line, and make a string of the headers.
            def end-of-line = {chars.find '\n'}
            {if end-of-line >= 0 then
                def first-line = {{chars.substr 0, end-of-line}.trim-clone}
                def command-pieces = {first-line.split split-chars = ' '}

This is not top-level code but code in a procedure within a class so  def   is used without braces.  The docs suggest the use of curly braces around a {def } expression when it is class-level or top-level so as to be distinct in appearance from local declarations.  The code is easy to read, there are few type declarations and any later destructive assignment is precluded.

Note that in the case of
   def (num-bytes-decoded, chars) =
the procedure  {decode-characters } itself returns
   (num-bytes-decoded:int, chars:String)
but such an expression might have returned more than two values with the surplus ignored by the def macro in its assignments.

The def  of an object reference to an instance of a class can preclude bugs and undesired ad hoc "bug fixes" and keep code readable as well as facilitate testing.

implicit primitive

An implicit constructor or factory can convert its single argument to a chosen type.

A class may be declared with more than one as implicit  and they will be searched in their declaration order for the first one which can be applied to the argument.

There are a few restrictions but they are not too subtle and they are detailed in the docs.

The important reminder from the docs might be this:
The choice of which implicit constructor or factory to call depends on the runtime type of the value [of the argument passed] (my emphasis and parenthetical addition)
An interesting example can be found by looking into the Curl constants named curl-version and curl-version-number.  The latter is an instance of a VersionNumber.

The implicit factory for VersionNumber is documented as

  public implicit
   {VersionNumber.from-string
     string:StringInterface
   }:VersionNumber

The Curl docs provide a live-code working example.  Here is my code from my simplified version of the example:

  {define-proc {make-version-table  ...:VersionNumber}:Table

and here is how to execute the procedure:

  {make-version-table "7.0.1", "7.0.3+"}

Looking at the last the two REST arguments you can see how smart this is.

The code in the Curl example uses a loop:

  {for version-num key i in ... do

  }

and in the loop that local var version-num is sent a VersionNumber clone method named

  n-clone

as in

  { version.n-clone n = j }     ||  j is a loop counter in my simplified version

to clone selected portions of the version number object.

All we have are strings but the code also includes no asa operator doing any type casts.

NOTE:  (a quote from the Curl docs)
You can also use asa to convert a value to a class type, providing there is a corresponding implicit constructor or factory in the class.

Wednesday, April 6, 2011

Rilke links in Curl

I added a simple web page with links to Rilke's Letters to a Young Poet.  Those pages are themselves in German, so I didn't anticipate any problem.  But when I did a simple edit to the Curl page in a cpanel text editor on my linux host, things began to go wrong.  All that I needed were the characters ä and å in the Windows-1252 encoding. I had chosen this character encodiing to investigate a quirk in the Opera browser.  But how to get the characters into the cpanel editor?

The Windows clipboard kept being "smart" and forcing the characters into 16-bit Unicode (the cahracters above were added using HTML entities - not an option in the source of the Curl text file.

Then a solution dawned on me: don't use an editor. Use the Windows command line! ALT-0228 and ALT-0229 on a cmd command line, mark, copy, paste into the web page for the cpanel editor (with the Curl file carefully re-loaded by the editor in Windows-1252) and all displayed correctly when the applet loaded.

The HTML file in which the Curl is an embedded Object is set to "windows-1252" and the Curl source file is set with a document character encoding on "win32:1252".

Tuesday, April 5, 2011

Curl character encodings

I have added a post above displaying the CharEncoding which Curl 7.0 offers on my Windows installation.

The two lists there cover more than 100 character encodings: both are from the procedure {get‑all‑character‑encodings} (note the use of & # 8209 ; to get that procedure name to appear here with non-breaking hyphens.)

The reason for using them is that Curl offers a CharEncoding class feature to obtain an instance by name - but the docs had no complete list of names, no doubt because the HostEncoding instances will vary by platform and current installation.

One dump is from a breakpoint in the debugger and one is console output from a loop over the {Array‑of CharEncoding} which is returned by the proc.

The types in that container include:

NoneCharEncoding
ShiftJISCharEncoding
EUCJPCharEncoding
UTF8CharEncoding
UTF16CharEncoding
UTF16UnknownEndianCharEncoding
SingleByteCharEncoding
MappedSingleByteCharEncoding
HostEncoding

with most being in the last.  The first is a system default for no encoding specified.

I happened to note that the Curl mother site www.curlap.com pages are encoded in Shift‑JIS.

A few days ago I noticed that some Classical Greek in UNICODE (UTF‑16) displays correctly in the Curl 7.0 IDE but not in any of my Windows web browsers.  I have not yet tested a Curl desktop Dcurl application to see if the UTF‑16 presents correctly in an RIA test.

By way of contrast, the current Pharo Smaltalk environment offers 14 encodings for Workspace contents. EncodedCharSet in Pharo currently has subclasses for GB2312, JISX0208, KSX1001, Latin1 and Unicode.