Forum OpenACS Development: Re: OpenACS, XoTcl, and ActiveRecord

Posted by Steve Manning on
Quoting from the TCL man:

"[split] Returns a list created by splitting string at each character that is in the splitChars argument. Each element of the result list will consist of the characters from string that lie between instances of the characters in splitChars. Empty list elements will be generated if string contains adjacent characters in splitChars, or if the first or last character of string is in splitChars. If splitChars is an empty string then each character of string becomes a separate element of the result list. SplitChars defaults to the standard white-space characters."

Therefore if I'm not mistaken:

[split [self] ::]

will attempt to split self by ':' and ':' rather than '::' which will produce an empty string between each element e.g

set self "mytcl::namespace::isgroovy"
split $self ::

gives a list of 5 elements:

mytcl {} namespace {} isgroovy

rather than a list of three elements:

mytcl namespace isgroovy

I get round this by regsubbing a safe chr inplace of the string then splitting on that chr.

I don't know if that is the desired effects - I'm just poking my nose in.

    - Steve

Posted by Tom Jackson on

If the string returned by [self] is a namespace, or qualified procedure name, you really should use the namespace commands to figure out what the tail is. The reason is that ':' is an allowed character in procedure names, and '::', ':::' and '::::' are all equivalent in meaning for qualified names in tcl. The resultant code is also easier to read and maintain.