I suspected as much. I didn't know all that history on the names. I like Oleg's suggestion to put the names for the primitives into a separate locale. That way the conflicts with names already in the "z" locale can be avoided with a little planning.

No one should be using primitiv.ijs except for teaching or beginners. In those cases there will probably be some application written for them to use which can avoid the name conflict problems.

I ran into this when updating the "Primitives to Mnemonics" script to J6 (finally). I was surprised that primitiv.ijs had changed so much. I thought the only problem would be using dotted names.

Fraser Jackson wrote:

Don Guinn wrote:


Loading primitiv.ijs clobbers the name "open" in the z locale.

When the names are defined in the z locale CamelCase is converted to lower case as described in Note at the beginning of the script. This results in the CamelCase name "Open" for ">" to be converted to "open" wiping out the
"open_z_" verb. The remarks says that all one needs to do is remove the
"tolower" in line 247 of the script, but that doesn't address the problem
of the name conflict for the name "open".


If you use CamelCase the name "Open" is defined, and the name "open" retains
the usage for opening a file.  The above statement then only becomes a
problem if the user does not distinguish "Open" from "open".

Should the name for ">" be changed to something else?


It would be extraordinary to change ">" to some name other than "open"
given both its historic use, its use in the Dictionary, and the relative
importance of this function in virtually every script.  To open
a boxed object is surely the commonest opening operation in J by far
(probably several orders of magnitude).

If you scan the provided script libraries there are many functions to
open different objects. I stopped listing names including "open" after
about 20 of them.  I personally think it would be better to rename the
existing "open" function to something else like  "fopen" or "openfl" to
indicate what is being opened. The existing function is not listed in the User Guide under the Script Libraries so clearly a range of standard system functions are not listed there and there may be some conflicts not referred
to below.

It was one of Ken's objectives to get children to use the notation he had
devised.  In my experience children find it hard to understand that words
with a capital always refer to something different from words without one.
Capitals may begin a sentence but capitals usually only begin some words
within it. The two words mean the same to them. They also know that a word
can have two different meanings and we use the one appropriate to its
context.  Unfortunately J does not do this for us.  It makes it very
difficult to use the primitive names if children must always begin every
word referring to a primitive with capitals, and include capitals at some
points within them. I tried it out recently also with a visiting professor who had experience of using a wide range of languages, and insisted applications using J would never get wide usage unless single case words for the primitives were available.

And how many other

conflicts are generated by not keeping CamelCase? Or should we only deal
with CamelCase for the primitive names?


It would be very difficult to ensure that any script excludes all possible name conflicts. That is why locales are so important as Oleg noted. Using 'primitives' however means it must be in the path and some other names will
be hidden.

The primitives script notes:

"Using lower case names means that verbs sort and table in the standard
libraries will be hidden, and new definitions used. No other standard
library verbs should be affected. The verbs max, min, cut, rotate and deal
also differ from verbs with these names in scripts
'stats','strings','isigraph' or 'random'."

"open" needs to be added to the list of verbs in the standard libraries
which are modified.

The question then becomes, "Is it important to preserve the small number of
verbs in the standard libraries which conflict with these names, or to
preserve consistency with the Dictionary, and the simplicity of using lower
case?" For the group of users likely to use 'primitives' I believe
consistency and simplicity are the dominant considerations.

For that group, the present default is preferable, but for more experienced
users, CamelCase will provide greater security against the potential of
unknown name conflicts and it is clearly indicated how it can be used.

Fraser
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to