not a lot of people know that v2.0 andy shiers, coo
DESCRIPTION
Capsules A capsule is the outermost dfn of a (possibly empty) set of nested dfns Some editor and tracer features work at the capsule level The concept of the capsule is likely to become more prominent in future versionsTRANSCRIPT
Not a lot of people know that v2.0Andy Shiers, COO
2
Synopsis• We should have said ..
– Miscellaneous notes from earlier presentations• I'd like to point out ..
– Some small but important/interesting things• A regular favourite ..
– Editor and Tracer• What's in a (workspace) name ..
– Well, it's obvious, innit ?• What does that mean ..
– A small comment hides a wealth of interest ..• That’s All Folks
Capsules• A capsule is the outermost dfn of a
(possibly empty) set of nested dfns • Some editor and tracer features work
at the capsule level• The concept of the capsule is likely to
become more prominent in future versions
Scripted Objects• In 14.1 you cannot have two
definitions of the same-named one-line dfn– This is now consistent with attempts to
redefine tradfns and multi-line dfns
:Namespace andys foo←{⍺ ⍵} foo←{⍺,⍵} :Endnamespace
Will not fix !
Altering the Language Bar• Have always been able to adjust it• Was all too easy to delete entries• In 14.1 can now Reset to default
• For earlier versions, send us an email.
• Applies to old IDE only– RIDE language bar is not alterable
Editor/Tracer
• dfns: can now view ⍺ ⍺⍺ ⍵ ⍵⍵– Unlikely to make these editable– Unlikely to add ∇ - you're already looking
at it !
Editor/Tracer• Align Comments:
– 14.0: Worked only in simple functions– 14.1: Works in scripted objects too
• On selected text• On current tradfn
– Any dfns defined in tradfn will also have comments aligned
• On current capsule
Editor/Tracer• Skipping lines
– 14.0: • can select Skip Blank Lines and Comments
or not– 14.1:
• can select Skip Blank Lines or not• can select Skip Comment Lines or not
– Still always stops on line[1]– Still always stops on the last line of a
tradfn
⎕ED and Variants• ReadOnly: 0 or 1
– Only allows you to not alter an object that by default could be altered
– Doesn't enable editing of objects that cannot be altered !
• EditName: Default, Allow, Disallow– Returns list of names that have changed or
been created– Default is Disallow, it will always remain so
Workspace filenames)save myws
Windows 14.0 and prior:
myws.DWS14.1
myws.dws
WSEXT• Windows users expect file extensions,
UNIX users (generally) don't• There is no one "right" way
– ⎕io– vi vs emacs
Of course there is: correct answers are none, 1, vi
• Need cross-platform support– 'DRC' ⎕cy'conga'– We see more multi-platform systems now
WSEXT• WSEXT
– Defines what APL appends to filenames– Allows cross-platform code to be written– But
• Can cause some confusion• May cause apparently odd errors
WSEXT• WSEXT
– is a colon delimited list– elements can be empty– it is a standard configuration parameter– First element is used by default for )SAVE
• WSEXT default values:– Windows .dws:– Non-Windows :.dws:.DWS
WSEXT• Be aware of interaction between WSEXT and
WSPATH– outer loop is elements of WSEXT– inner loop is element of WSPATH– for all but )DROP, the first hit is the one that is used
• for )DROP for multiple hits, all are displayed and nothing is deleted
WSEXT• )WSID always includes any file extension• On Windows all system commands that report
workspace names will have at least one "." in each name
• No changes have been made to ⎕WSID
Shared pockets and 127⌶
• 127⌶: Overwrite Free Pockets– "It is the responsibility of the
programmer to ensure that there are no USED pockets in the workspace that reference the data."
– What's this all about ?
Shared pockets and 127⌶
• Will mention:– Pockets– ⎕wa, 2000⌶, ⎕size, ⎕dm/⎕dmx
• Won't mention:– Much of what is in a pocket, much of what is in
a workspace (will not be documented)– How memory is managed (partially
documented)
Let's have some data !
04W24W0W04100000W40000110W020000401000W000000000101000011W0011200010040040000W1W30000000000000400000000000001004W
2015-08-06
Isn't Key wonderful ?
a←'04W24W0W04100000W40000110W020000401000W000000000101000011W0011200010040040000W1W30000000000000400000000000001004W' {⍵[⍋⍵[;1];]} ,∘≢⌸a0 771 132 33 14 9W 10
• (,∘≢⌸a can be written as {⍺,≢⍵}⌸a)
• For England supporters: isn't that a wonderful thing to behold ?
What is a Workspace ?
A lot of pockets, a lot of pointers
Symbol
Class
Free space
DMX
OthersSymbolData Data Data Free spaceOthers ..
Symbol Symbol Free space Function Others ..
Data Pocket
Data:04W24W0W04100000W40000110W020000401000W000000000101000011W0011200010040040000W1W30000000000000400000000000001004W
Other meta data
Type: CharacterRank: 1Length: 113
Data Pocket
A Simple VariableInnings←'04W24W..'
Other meta data
Type: SymbolName: InningsValue:
Data:04W24W0W04100000W40000110W020000401000W000000000101000011W0011200010040040000W1W30000000000000400000000000001004W
Other meta data
Type: CharacterRank: 1Length: 113
A Nested VariableInnings2←⊂'04W24W..'
Other meta data
Type: SymbolName: Innings2Value:
Data:04W24W0W04100000W40000110W020000401000W000000000101000011W0011200010040040000W1W30000000000000400000000000001004W
Other meta data
Type: CharacterRank: 1Length: 113
Data:Other meta data
Type: PointerRank: 0Length: -
Sharing PocketsWorthRepeating←5 2⍴⊂Innings
Data:04W24W0W04100000W40000110W020000401000W000000000101000011W0011200010040040000W1W30000000000000400000000000001004W
Other meta data
Type: CharacterRank: 1Length: 113
Other meta data
Type: SymbolName: InningsValue:
Other meta data
Type: SymbolName:WorthRepeatingValue:
Data:Other meta data
Type: PointerRank: 2Lengths: 5 2
No automatic sharing a←'Hello'
– Pocket 1: » Symbol: Name: a, Value: pointer to
– Pocket 2: » Data: Value: Hello
b←'Hello'
– Pocket 3: » Symbol: Name: b, Value: pointer to
– Pocket 4: » Data: Value: Hello
Sharing pockets a←'Hello'
– Pocket 1: » Symbol: Name: a, Value: pointer to
– Pocket 2: » Data: Value: Hello
b←a– Pocket 3:
» Symbol: Name b, Value: pointer to Pocket 2
c←2e6⍴⊂a– Pocket 4:
» Symbol: Name c, Value: pointer to Pocket 5– Pocket 5:
» Data: Value: 2e6 pointers to Pocket 2– c apparently takes up more space than there is in the workspace
Shared pockets can easily stop being shared
c,¨←'a'WS FULL
• Each element has to be generated• Each element is separate from all others
c[2],←'a'• .. ((¯1+2e6)⍴⊂'hello') and 1⍴⊂'helloa'
Some useful system functions
• ⎕SIZE– Reports what the object would take up if no pocket sharing
occurring– Is best used on numeric/character data– Is of little practical use
• ⎕WA– Reports how much free space left in workspace– Is a "heavy" operation
• Forces a compaction• Forces all data to be squeezed where possible
• ⎕DR– Monadic use reports the data type
• Squeezes the data first if possible
Some useful I-Beams• 2000⌶
– 0: A quick ⎕WA• No Compaction, no squeeze, some approximation
– 1: Workspace used• Some approximation of more complex structures
– 2: Number of compactions since last workspace loaded• Keep this as small as possible !• Includes number of calls to WA⎕
• 2002⌶– "⎕WA and a bit"
• Keeps a bit more workspace available• 181⌶
– "⎕DR without the squeeze"• Squeeze is possible if a compaction happens when returning result !
So what about that comment ?'andys'⎕ns'' ⋄ define foo ⋄ foo
Other meta data
Type: FunctionName: fooOther_stuff:
Other meta data
Type: SymbolName: andysValue:
Other meta data
Type: NamespaceName: andysContents:
∇ foo;secret[1] secret←'MySecret'[2] :Trap 0[3] ÷0[4] :EndTrap ∇
Other meta data
Type: SymbolName: secretValue:
Other meta data
Type: CharacterRank: 1 Length: 8Value: MySecret
Other meta data
Type: DM(X)⎕
Delete the namespace)erase andys
Other meta data
Type: FunctionName: fooOther_stuff:
Other meta data
Type: SymbolName: andysValue:
Other meta data
Type: NamespaceName: andysContents:
∇ foo;secret[1] secret←'MySecret'[2] :Trap 0[3] ÷0[4] :EndTrap ∇
Other meta data
Type: SymbolName: secretValue:
Other meta data
Type: CharacterRank: 1 Length: 8Value: MySecret
Other meta data
Type: DM(X)⎕
Clear up: ÷0
Other meta data
Type: FunctionName: fooOther_stuff:
Contents:
Other meta data
∇ foo;secret[1] secret←'MySecret'[2] :Trap 0[3] ÷0[4] :EndTrap ∇
Other meta data
Type: SymbolName: secretValue:
Other meta data
Type: CharacterRank: 1 Length: 8Value: MySecret
Type: Namespace
Other meta data
Type: DM(X)⎕
Other meta data
Type: ÷0 error
Ask yourself• When using 127⌶:
– Have you shared that sensitive data pocket ?– Have you unintentionally shared that sensitive data
pocket?
• When saving a workspace:– Is it worth running )RESET– Is it worth )SAVEing the workspace and then )COPYing it into a CLEAR
WS ?
• When developing code:– What am I hoping to learn by using ⎕SIZE/⎕WA/⎕DR ?– Make use of 2000⌶