Tags:
create new tag
view all tags

Feature Proposal: Implement GET and SET Variables as Convenience Functions

Motivation

At present, we need to go through CALC to set and get variables.

%SET{Var, value)% would be a handy shortcut for %CALC{"$SET(Var, value)")%.

Likewise %GET{Var}% would be a handy shortcut for %CALC{"$GET(Var)")%.

Description and Documentation

Description of what this feature should do

Examples

Impact

Implementation

-- Contributors: VickiBrown - 02 Aug 2008

Discussion

Note for the unwary; this does not describe a generic "set" function for TWiki variables. The proposal relates to SpreadSheetPlugin variables only.

I have a couple of concerns:

  • The parameter syntax =%SET{name, value}% is not supported by TWiki variable syntax (there is no concept of a comma-separated parameter list). You could write %SET{name="value"}% however.
  • As mentioned before, these variables exist in the SpreadSheetPlugin namespace only, and that namespace is not open to other plugins. GET and SET are very "generic" names, and reserving them for the exclusive use of the SpreadSheetPlugin would preclude their later use in the core for the manipulation of TWiki Variables.
In general I think that it would be better to revisit the syntax of %CALC statements. It always struck me as strange that I couldn't set a variable using %CALC{"var=value"}% or retrieve a value using%CALC{"value?"}% (or something like that).

-- CrawfordCurrie - 02 Aug 2008

I share Crawford's concern that these variables would seem to be much more useful in some future context of TWiki itself.

-- DavidWolfe - 02 Aug 2008

It is only natural to set and get variables in something that is nearly a programming language. From what I see this feature could be implemented by leveraging setting perference variables to TWikiApplications using standard TML instead of * Set VAR. Maybe, there's no need to have yet another namespace for yet another kind of variables.

Instead, we should use those "variable concepts" as they are available in standard TWiki.

%CALC{}% is processed outside the normal processing flow of the TML parser. That's because %CALC{}% is implemented using commonTagsHandler() instead of using registerTagHandler(). SpreadSheetPlugin has got its own internal parser for TML to cope with TWikiTables and ordering semantics. This, however, interferes with other plugins that register their tags regularly to the TWiki parsers, alas can't be mixed and nested with %CALC{}% as you'd think in the first place.

TWiki's normal evaluation order could still result in "interesting" sideeffects for SET & GET. Infact, any natural interpretation (by human programmers) of GET & SET might contradict with TWiki's current evaluation order. For one, what is the result of a GET when a SET occurs before or after on the same page?

-- MichaelDaum - 02 Aug 2008

This is now handled by the SetAndGetVariables proposal.

-- PeterThoeny - 2010-07-29

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2010-07-29 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.