slang-users mailing list

[2013 Date Index] [2013 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Convert string into function qualifiers?


Hi,

qualifiers are internally the fields of a structure, which can in turn
be passed to a function, namely after a double-semicolon:

  variable my_qualifiers = struct { s, q="<10", k };
  foobar(23;; my_qualifiers);

(Since you were asking how to convert a string into qualifiers, you just
need to split the string and to produce the appropriate structure.)

By the way:
As one cannot combine qualifiers "as qualifiers" (after a semicolon) and
qualifiers as structures (after a double semicolon) in one call, one has
to merge the structs in such a case:

  variable all_my_qualifiers
	= struct_combine( my_qualifiers, struct { p=0.1 } );

Since S-Lang pre2.2.3-39 (or so), one can "dereference" struct fields
(with @), which can be used both for merging structs:

  variable all_my_qualifiers = struct { @my_qualifiers, p=0.1 };
  foobar(23;; all_my_qualifiers);

... and qualifiers:

  foobar(23; @my_qualifiers, p=0.1);

Note that the above will always set p=0.1 for foobar, while

  foobar(23; p=0.1, @my_qualifiers);

merely provides a default value for p, which might be overridden by
my_qualifiers, if it also contains a field "p".

Cheers,

Manfred


On 02/11/2013 02:11 AM, J.B. Nicholson-Owens wrote:
> I'm using S-Lang version 2.1 or later (where qualifiers were introduced) 
> and I'm reading S-Lang function argument qualifiers from a file. 
> Therefore, I've got the qualifiers as a string.
> 
> I'd like to pass this string on to a function as a set of qualifiers 
> doing something like the following:
> 
>    variable my_qualifiers = "s,q=\"<10\",k";
>    foobar (23; my_qualifiers);
> 
> Any suggestions on how I'd do that?
> 
> Thanks.




[2013 date index] [2013 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]