Tuesday, November 25, 2008

Unicode in Squeak

(Excuse the odd formatting; blogger.com isn't liking my Unicode symbols in this post and is doing odd things with line heights)

Somebody on the Squeak mailing list asked about how to do an open Interval. I came up with:

1 to: ∞

I had added "∞" as a global variable equal to "Float infinity" and my example... just worked! When I was looking at the character table for the infinity sign, I came across a ton of other gems. These would be all quite possible in Squeak, and many of them trivial.

( (22 ÷ 7) ≈ (π ± ¼) ) → true or false, π and ¼ are constants and ± would return an object representing a numeric accuracy object of some sort.
((c ∪ d) ⊂ e) → true or false for collections c, d, and e.
(a ∧ b ∨ c) ¬ " The not-sign needs to come after expressions. "

1 … 3 → returns an interval. The ellipses is a single Unicode character.
2¹⁶ → 2 raisedTo: 16.
∅ → An empty, immutable Set instance.

There are loads of symbols available that would work as constants, method selectors, variables (greek letters anybody?) and so forth. Some of them won't work, such as using a dollar-sign for currency values. I'm not sure about '∃' and '∀' because of Smalltalk's message order; these two symbols are some odd prefix-type expression.

Another useful symbol would be some sort of concatenation operator, but (not being a proper mathematician) I don't know one. This operator would allow you to easily make a collection, e.g.

#a | ∅ " A new set containing #a. This could be implemented, but '|' is already used in Boolean operations. "
varA | varB | varC | ∅ " Shorthand for making a collection. Replace '∅' to change the type of collection. "

There's a Unicode character called a "Character tie": http://www.fileformat.info/info/unicode/char/2040/index.htm. Would this make a potential concatenation operator?:

varA ⁀ varB ⁀ varC ⁀ ∅ " Meh "

Tuesday, November 4, 2008

Subcanvas: first graphics.

A screenshot:

What is it? Well, it's an orange line, green rectangle, filled blue rectangle and small blue bit of text. The relevance here is that I've gotten some basic graphics output from Subcanvas.

The features that you aren't seeing here are:
  • The code for this is in a Package, and the classes are all in Namespaces. Namespaces really work! Although... I have found some more nasty bugs that destroy code.
  • The coordinates used are measured in micrometers. Those are 20mm by 20mm boxes on my screen, roughly.
My next steps are to add support for child canvases and keyboard / mouse event handling.

Saturday, October 25, 2008

SecureSqueak - what is it exactly?

I've decided to start a blog about SecureSqueak, and maybe other Smalltalk-related topics.

SecureSqueak is Squeak modified to run untrusted code. Code should be able to be loaded from a remote site and executed locally without any damage or unauthorised access to the local system. It is intended to be a kernel for my other unnamed project which is currently going by the name of "Unnamed Grand Project".

SecureSqueak has been in stasus for a while while I pursued a rather less worthy topic: Warzone 2100. Yes, I wasted a few hours of my life!

So now I'm back in action. The next few items on the agenda are:
  • Get Subcanvas working. Subcanvas is an enhanced version of the Canvas class which will provide the basic graphics and input handling to SecureSqueak. Subcanvas is also a test bed to see how well I can write code using my recently developed Namespaces for Squeak.
  • Write another simple SiteBrowser package. This isn't part of SecureSqueak but rather the UGP. This will let the user navigate through distributed objects.
  • Get the package distribution (i.e. remote code loading) for UGP working.
Igor Stasenko provided some valuable feedback on the design of Namespaces. Once I've finished the above, I'll be looking at refactoring the namespaces system and put the code for managing namespaces, classes and methods in a namespace itself. Currently the code for managing namespaces sits in the SystemDictionary and is saved at http://squeaksource.com/SecureSqueak, but I eventually plan to deprecate and perhaps even remove the SystemDictionary from the image.

Want to see the code? Well, it's scattered all over the place:

Documentation is at http://gulik.pbwiki.com/.
Code in the SystemDictionary (i.e. most of it) is at http://squeaksource.com/SecureSqueak/.
Code in Namespaces and image files are stored at http://securesqueak.sourceforge.net/.