How do I stay organized in apl2 ? 
Author Message
 How do I stay organized in apl2 ?

Henrick Jeanty:
[wants suggestions on recognizing temporary global variables in a
workspace.]

There are a number of techniques you can use:

[a] decide that *all* variables are temporary -- write a routine
called GLOBALVARS to build ones that you need.

[b] keep a list of all "desirable variables", erase everything not on
that list during cleanup.

[c] don't use workspaces as your unit of storage: keep everything out
on file, and build workspaces from these files [ala unix 'ld'].

[d] use a naming convention that allows you to rapidly determine the
longevity of an object.

[e] write a CLEANWS routine that encodes all your knowledge of a
workspace's structure.

[f] Then again, maybe the apl you're using gives you a mechanism of
examining workspace and variable time stamps?  If not, perhaps you can
write a routine to run at load time to implement something analogous
to [b]?

Raul D. Miller             n =: p*q               NB. prime p, q, e

                           y =: n&|&(*&x)^:e 1
                           x -: n&|&(*&y)^:d 1    NB. 1 < (d*e) +.&<: (p,q)



Tue, 14 Jan 1997 05:51:44 GMT  
 How do I stay organized in apl2 ?
I am using APL2 for OS/2 at work and am having a little trouble staying
organized. My problem is as follows. I have a workspace with many functions
and variables that come from Libs I have brought in by using )COPY. I now
write a few more functions and use a few more variables to test some routines.
I now want to save the workspace, but want to remove all those temporary
variables I created while experimenting. Now comes the problem. I can't
remember the names of all the variables I have created. If I type the command
)VARS, I get a list of all the variables in the workspace and it becomes
tedious to try and figure out which ones I created and which ones are used by
the original workspace.
Coming from a traditional C and C++ programming background I never had that
problem before. All the variable I created were located in source files.
My question is this:
Does anybody have an original (and easy) way to somehow get a list of the
variables that were created since a workspace was loaded ? Given that list I
could then )ERASE all the variables I had created for temporary experimental
usage.

Thanks in advance for all suggestions
Henrick Jeanty Ph.D.



Mon, 13 Jan 1997 22:22:11 GMT  
 How do I stay organized in apl2 ?
David Liebtag:
.  You could convert all the global variables to nilladic functions,
.  set a trace vector on each of them, run your applications, and
.  notice which ones never execute.  Here's a way to convert them to
.  nilladic functions:
...
.  This should work if none of your variables are too large.

Alternatively, you could just stick some unused prefix on the variable
and have the niladic function merely be an alias for this name.  Of
course, you'll have to change back any variables which are assigned
(e.g. STACK[TOP]<-...).

Also be warned that this technique can fail if there is any code
explicitly testing a name to see if it's a variable name.

Another possible technique, if you can set up a global error handler
(to be executed at the point in the code where the error happens) is:
store all the variables in some other workspace or file, and each time
you get a value error, bring in the variable which is missing (then
continue on).  This one has two hazards: checks on the name class, and
the possibility of non-restartable code (e.g. code which produces side
effects on the same line as the missing variable, but before that
variable would be encountered) -- however, it is not very labor
intensive.

Raul D. Miller             n =: p*q               NB. prime p, q, e

                           y =: n&|&(*&x)^:e 1
                           x -: n&|&(*&y)^:d 1    NB. 1 < (d*e) +.&<: (p,q)



Wed, 15 Jan 1997 18:16:05 GMT  
 How do I stay organized in apl2 ?
Henrick,

You could convert all the global variables to nilladic
functions, set a trace vector on each of them, run your
applications, and notice which ones never execute.
Here's a way to convert them to nilladic functions:

  NL is Enclose[2] QuadNL 2
  TF is 2 QuadTF Each NL
  TF is (TF Iota Each 'Is') Drop Each TF
  QuadEx Disclose NL
  QuadFX Each ,/[1]Enclose Each Disclose((Enclose 'R is') ...
    , Each NL)((Enclose 'R is'), Each TF)

This should work if none of your variables are too large.

Regards,
David Liebtag
IBM APL Products and Services



Wed, 15 Jan 1997 03:44:43 GMT  
 How do I stay organized in apl2 ?
|> I am using APL2 for OS/2 at work and am having a little trouble staying
|> organized. My problem is as follows. I have a workspace with many functions
|> and variables that come from Libs I have brought in by using )COPY. I now
|> write a few more functions and use a few more variables to test some routines.
...

|> Does anybody have an original (and easy) way to somehow get a list of the
|> variables that were created since a workspace was loaded ? Given that list I
|> could then )ERASE all the variables I had created for temporary experimental
|> usage.

This last is fairly easy - just comapare the quad NL's of the original
and new ws. But it won't work for stuff copied in unless you saved the
ws before creating the temporary variables and functions.

Another way that will eventually work is to save the new ws, then
clear all variables, then try to run. You'll get error messages
telling you what to load next - should be value errors. This could
even be automated... with another temporary function!

--
Sam Sirlin



Wed, 15 Jan 1997 05:59:26 GMT  
 How do I stay organized in apl2 ?
I haven't used a workspace in years. All functions and
permanent variables reside on files, each component being
a 'group' of objects.

I have one workspace containing a quad-lc statement which
boots up my whole environment. This is my only workspace.
I never save a workspace. Never.

One file stores 'system' objects used in development and
run-time. Other files store individual applications.

--
Acces Public LLC      Site Internet Public      Ville de Quebec



Sat, 18 Jan 1997 07:29:15 GMT  
 How do I stay organized in apl2 ?

Quote:

>I am using APL2 for OS/2 at work and am having a little trouble staying
>organized. My problem is as follows. I have a workspace with many functions
>and variables that come from Libs I have brought in by using )COPY. I now
>write a few more functions and use a few more variables to test some routines.
>I now want to save the workspace, but want to remove all those temporary
>variables I created while experimenting. Now comes the problem. I can't
>remember the names of all the variables I have created. If I type the command
>)VARS, I get a list of all the variables in the workspace and it becomes
>tedious to try and figure out which ones I created and which ones are used by
>the original workspace.
>Coming from a traditional C and C++ programming background I never had that
>problem before. All the variable I created were located in source files.
>My question is this:
>Does anybody have an original (and easy) way to somehow get a list of the
>variables that were created since a workspace was loaded ? Given that list I
>could then )ERASE all the variables I had created for temporary experimental
>usage.

I've seen a couple of replies to this; but I wonder if you are looking for
a more basic answer...

Your questioning )VARS gives me the impression you may be new to APL and
you may be unaware of quad-NL (name list system function).  )VARS is just
a query of variable names that gives a formatted display.  Quad-NL 2 will
return a result of all variable names as a matrix, so you can actually
save the list for management of objects.  If you save Quad-NL 2 at the
beginning of your session in a some variable, then compare it with
quad-NL 2 later in your session, you can create a list of differences
that you can erase with quad-EX (quad-EX will erase names in a list
matrix, )ERASE will just do quick command-line erase).  You can also
manage functions and operators with quad-NL 3 and 4.

Look in your library workspaces for a utility or idiom phrase example for
comparing lists (two-dimension arrays), something like "row positions of
X in Y" or "rows of X found in Y".  You could then turn it into your own
cleanup function, choosing your own names for where to keep object lists.

Here's one example of finding differences -- in textified APL.  Note this
step only works if both lists are already the same width (2nd dimension),
but you get the idea...

      A <left arrow> 4 6 <rho> 'JOHN  PAUL  RINGO GEORGE'
      A
JOHN
PAUL
RINGO
GEORGE
      B <left arrow> A,|12 6 <rho> 'FRED  JOE   '
      B
JOHN
PAUL
RINGO
GEORGE
FRED
JOE
      ( <left shoe> |2B) <epsilon>  <left shoe> |2A
1 1 1 1 0 0
      ( <tilde> ( <left shoe> |2B) <epsilon>  <left shoe> |2A)/|1B
FRED
JOE

/
Charles A. Schulz



Sat, 18 Jan 1997 04:54:01 GMT  
 How do I stay organized in apl2 ?

Quote:



>>I am using APL2 for OS/2 at work and am having a little trouble staying
>>organized. My problem is as follows. I have a workspace with many functions

. . .

Quote:
>Here's one example of finding differences -- in textified APL.  Note this

Sorry, the brackets got eaten in this example and turned up as
"&" and "a".  Here's another try using "{}" for APL square brackets.

      A <left arrow> 4 6 <rho> 'JOHN  PAUL  RINGO GEORGE'
      A
JOHN
PAUL
RINGO
GEORGE
      B <left arrow> A,{1}2 6 <rho> 'FRED  JOE   '
      B
JOHN
PAUL
RINGO
GEORGE
FRED
JOE
      ( <left shoe> {2}B) <epsilon>  <left shoe> {2}A
1 1 1 1 0 0
      ( <tilde> ( <left shoe> {2}B) <epsilon>  <left shoe> {2}A)/{1}B
FRED
JOE

/
Charles A. Schulz



Sat, 18 Jan 1997 05:22:07 GMT  
 How do I stay organized in apl2 ?


Quote:


>>I am using APL2 for OS/2 at work and am having a little trouble staying
>>organized. [ ... ]

>Your questioning )VARS gives me the impression you may be new to APL and
>you may be unaware of quad-NL (name list system function).  [ ... ]

>Look in your library workspaces for a utility or idiom phrase example for
>comparing lists (two-dimension arrays), something like "row positions of
>X in Y" or "rows of X found in Y".  You could then turn it into your own
>cleanup function, choosing your own names for where to keep object lists.

>Here's one example of finding differences -- in textified APL.  Note this
>step only works if both lists are already the same width (2nd dimension),
>but you get the idea...

> [ ... ]

From the variety of articles in this thread, one can see that
managing lists of names isn't the only (or necessarily the best)
way to manage a workspace.  I only want to point out
that if you do want to follow this route, it is less
complicated than it would seem from the previous article.

In APL2 (and other modern dialects of APL, I'd assume),
it is not necessary to represent a list of words
as a matrix.  Instead, you can actually *have* a list of words.

Yes, you do have to deal with the fact that quadNL still returns
a matrix, and that the rows of the matrix are necessarily
padded with blanks.  But once you get around this,
you can dispense with utility functions for manipulating lists.
The primitive functions are enough.

How to get quadNL output into the form of a list (assuming quad IO is 0):

      A is enclose[1] quadNL 2          (list of variables, with extra blanks)
      A is A without each ' '           (delete blanks)

But again, name lists aren't the only approach.
If the originator of this thread weren't on a PC,
then I would've suggested looking at "packages."
Does anyone at IBM care to comment on whether these will
ever be available on PCs?
----------------------------------------------------------------------

Math Department
University of Chicago



Mon, 20 Jan 1997 10:53:14 GMT  
 How do I stay organized in apl2 ?


Quote:


>>I am using APL2 for OS/2 at work and am having a little trouble staying
>>organized. [ ... ]

>Your questioning )VARS gives me the impression you may be new to APL and
>you may be unaware of quad-NL (name list system function).  [ ... ]

>Look in your library workspaces for a utility or idiom phrase example for
>comparing lists (two-dimension arrays), something like "row positions of
>X in Y" or "rows of X found in Y".  You could then turn it into your own
>cleanup function, choosing your own names for where to keep object lists.

>Here's one example of finding differences -- in textified APL.  Note this
>step only works if both lists are already the same width (2nd dimension),
>but you get the idea...

> [ ... ]

From the variety of articles in this thread, one can see that
managing lists of names isn't the only (or necessarily the best)
way to manage a workspace.  I only want to point out
that if you do want to follow this route, it is less
complicated than it would seem from the previous article.

In APL2 (and other modern dialects of APL, I'd assume),
it is not necessary to represent a list of words
as a matrix.  Instead, you can actually *have* a list of words.

Yes, you do have to deal with the fact that quadNL still returns
a matrix, and that the rows of the matrix are necessarily
padded with blanks.  But once you get around this,
you can dispense with utility functions for manipulating lists.
The primitive functions are enough.

How to get quadNL output into the form of a list (assuming quad IO is 0):

      A is enclose[1] quadNL 2          (list of variables, with extra blanks)
      A is A without each ' '           (delete blanks)

But again, name lists aren't the only approach.
If the originator of this thread weren't on a PC,
then I would've suggested looking at "packages."
Does anyone at IBM care to comment on whether these will
ever be available on PCs?
----------------------------------------------------------------------

Math Department
University of Chicago



Mon, 20 Jan 1997 11:00:10 GMT  
 How do I stay organized in apl2 ?

Quote:

>Does anybody have an original (and easy) way to somehow get a list of the
>variables that were created since a workspace was loaded ? Given that list I
>could then )ERASE all the variables I had created for temporary experimental
>usage.

One method:
1. set quadLX to run a function which creates a list of vars when the ws is
loaded.
2. create a "clean-up" function, which compares available vars with list of vars
when ws was loaded, and blows away the difference.


Sun, 26 Jan 1997 12:41:51 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Career advice for the 21st century: Stay away from any job that can be done online

2. Career advice for the 21st century: Stay away from any job that can be done online

3. Terminate, Stay, and Stay active...

4. APL2/2 to APL2/W95/NT

5. Doing assembly and really doing assembly

6. Doing assembly and really doing assembly

7. The Key To Organizing Your Health Records

8. The Key To Organizing Your Health Records

9. organizing patches / change sets

10. Organizing a Parts App

11. Getting Organized

12. LAST CHANCE to co-organize OOPSLA Midyear Workshop

 

 
Powered by phpBB® Forum Software