Category:Wren-trait: Difference between revisions

Change to blurb following addition of Var and TypedVar classes.
(Changed blurb following addition of new classes.)
(Change to blurb following addition of Var and TypedVar classes.)
 
(4 intermediate revisions by the same user not shown)
Line 2:
'''Wren-trait''' is a module which provides the abstract classes: Comparable, Cloneable and CloneableSeq. The first of these enables child classes to easily support the basic comparison operators and the latter two enables such classes to identify themselves as ''cloneable'' given a suitable mechanism.
 
It also contains the wrapper classes: SteppedByRef, ReversedByKey, IndexedConst, ByRefVar and ByKey plus a helper class SeqEntryTypedVar. TheByRef firstenables two of these enablea sequencesvalue to be iteratedpassed in''by eitherreference'' (or both)to a steppedmethod fashionor (stepsfunction, >ByKey 1)enables ora inreference reverse.type Theobject thirdto enablesbe theused iterationas toa includeMap thekey zero-basedand indexConst ofrepresents thea sequencegroup elementsof andindividually SeqEntrynamed assists withread-only thisvalues.
 
Var represents a group of individually named read/write values. It can be used to simulate the creation of variables at runtime. It can also be used to allow variable names which would otherwise be illegal in Wren such as those which include non-ASCII characters.
ByRef enables a value to be passed ''by reference'' to a method or function and ByKey enables a reference type object to be used as a Map key.
 
TypedVar is similar to Var except that the simulated variables always retain the same type as they had when they were originally created.
It is the fifth in a series of modules (listed on the language's [[https://rosettacode.org/wiki/Category:Wren main page]]) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily. It is also small enough to be used by other modules in the series which are usually organized and written to avoid inter-dependencies.
 
It is the fifth in a series of modules (listed on the language's [[https://rosettacode.org/wiki/Category:Wren |main page]]) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily. It is also small enough to be used by other modules in the series which are usually organized and written to avoid inter-dependencies.
To use it all you need to do is to copy the source code (in the [[https://rosettacode.org/wiki/Category_talk:Wren-trait talk page]]) to a text file called ''trait.wren'' and place this in the same directory as the importing script or module so the command line interpreter can find it.
 
To use it all you need to do is to copy the source code (in the [[https://rosettacode.org/wiki/Category_talk:Wren-trait |talk page]]) to a text file called ''trait.wren'' and place this in the same directory as the importing script or module so the command line interpreter can find it.
9,476

edits