Monday, December 13, 2010

Curl ain't JavaScript/ECMAScript

A question was posted over at developers.curl.com about creating a an off-screen 2D Drawable that exceeds a Curl sanity check on screen resolution.

A Curl developer should be able to bypass the current 'reasonable guess-timate' limit with the expression
{Drawable.set-bypass-size-restriction? true}
prior to using a
{Renderer2d.create-offscreen ... }
The docs offer this practical test:
let display-context:DisplayContext =
{get-default-display-context}
let resolution:Resolution = 1 / display-context.pixel-size

There was a time when this was worrisome: we offered opportunities for staff with domain expertise to work in Smalltalk - but in the day of math coprocessor-on-the-board or not it was important to watch out for division.  In other languages we tried not to offer examples using division when multiplication was mandated - but Smalltalk was an exception because it offered rationals.

In code such as the example which would execute once, this really is a non-issue.  but all the same - this should have been
1 div display-context.pixel-size
to return an integer value.  Now for inverse or reciprocals.

In Curl, the exponent approach to obtaining a multiplicative inverse is
{pow n, -1}
The Curl compiler package contains the trig functions but no inverse function ( the Quaternion package has an invert and there are other inverse functions.)

The example becomes
{let display-context:DisplayContext =
    {get-default-display-context}}
{let resolution:Resolution = {pow display-context.pixel-size, -1 }}
But is this needed on current hardware?  Or is the compiler addressing this?

In JavaScript, the developer has the Math object and any available packages (  Python recently replaced numpy.)  But in Curl, the trig functions are addressed by the compiler.

Screen resolution itself poses a JavaScript and server issue because now the programmer is dependent on the browser supporting screen.width as a feature and likely a cookie.  It is much less an issue in Curl.  and that is before looking at CSS versus Curl styles.

Curl also offers this declaration in the docs:
{Display.set-resolution-mode
      mode:ResolutionMode,
      override-value:Resolution = 0dpi
}:void
as well as
public   {Display.get-displays}:{Iterator-of Display}
Moving on to Curl and 3D graphics - I see this for HTML5

Extensive work on Curl 2D dates back to a PhD done in 2001?
Curl 3D
[ to be continued ]

No comments: