Hello!

  Once again I'm amazed, in a good way, by Factor.

  I have tried a while ago to use typed slots as much as possible, but soon 
found out that if I want a slot to be integer, I can't have an "undefined" 
value for it:

`TUPLE: opt-coord { x integer initial: f } { y integer initial: f } ;`

  What I wanted is to either have no value (f), or an integer value, but 
nothing else in those slots. No strings, no sequences or other tuples.

  The problem with the above declaration is that `f` is not of type `integer`, 
so it neither can be the initial value, nor can it be assigned later on.

  While digging through the XML writer documentation I stumbled upon this 
definition:

```
USING: strings ;
IN: xml.data
TUPLE: name
    { space maybe{ string } initial: f }
    { main string initial: "" }
    { url maybe{ string } initial: f } ;
```

  You see those `maybe{` words? What are they, I wondered, and looked up their 
help. It was empty.

  I tried re-reading everything there is on the tuple definition, construction 
and slot declarations. No mention of `maybe{`.

  Yet it works exactly the way I wanted: it allows you to assign either the 
specified type(s) or `f` to a slot.

  That's a very useful feature, and it seems to be there for five years! But 
why is it not described or even mentioned?

---=====--- 
 Александр

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to