Requests for J base library extensions and enhancements.
Closed requests and responses in 2005.
Contents
- environment variables
- gl2 enhancements
- sdasync for UNIX
- wd tooltips
- wd to support more events
- session executed lines
- Input Log leading spaces
- mechanism to detect mapped name
- Easy Reference to the Directory of a Script File
- Enhancement to csv.ijs
- Enhancement to verb dstat
- 'trace' should warn about special variables
- Library categories for Project Manager
- Addon scripts available in Project Manager
- Simplify setting up multiple users for J
- Consistent interface to fappends and fwrites
- Addition of namedoc
- An assortment of notes on Application Distribution and Project Manager
environment variables
J should have a mechanism for setting environmental variables. -- Raul Miller 2005-11-05 20:49:39
--- the 2!: verbs allow for this, but not in Windows
-- RandyMacDonald 2005-11-06 05:05:38
2!:5 'WINDIR' seems to work under windows, but there's no corresponding verb to set an environmental variable (which can be important when using the host commands), so I've left my "setting" request and deleted my "reading" request. -- Raul Miller 2005-11-06 15:56:13
gl2 enhancements
It is proposed to update gl2 commands to match more recent 2D rendering engines. Here's some ideas.
- use antialiased fonts and geometry
- extend commands with features similar to
glquad x1 y1 cx cy x2 y2 glquads x1 y1 cx1 cy1 x2 y2 cx2 cy2 x3 y3 ... glqgon x1 y1 cx1 cy1 x2 y2 cx2 cy2 x3 y3 ... glcurve x1 y1 cx1 cy1 cx2 cy2 x2 y2 glcurves x1 y1 cx1 cy1 cx2 cy2 x2 y2 ... glcgon x1 y1 cx1 cy1 cx2 cy2 x2 y2 ... glbegin x y NB. path construction gllineto x y gllinesto x1 y1 x2 y2 ... glquadto cx cy x2 y2 glquadsto cx1 cy1 x2 y2 cx2 cy2 x3 y3 ... glcurveto cx1 cy1 cx2 cy2 x2 y2 glcurvesto cx1 cy1 cx2 cy2 x2 y2 ... glarcto cx cy x2 y2 NB. point on arc glclose '' NB. gllineto begin glstroke '' glfill '' glrgb r g b [a] NB. alpha opacity gllingrad x1 y1 x2 y2 r1 g1 b1 [a1] NB. first color from glrgb glradgrad x1 y1 x2 y2 x3 y3 r1 g1 b1 [a1] NB. radial gradient - tilted ellipse glpixelbrush x y w h pixeldata glpen i [style [join]] NB. bevel, miter, round
-- OlegKobchenko 2006-02-27 11:17:47
I'd like to second this request. The anti-aliasing would be especially nice. Paths/Curves and opacity would also be great.
-- RicSherlock 2008-02-08 03:40:20
sdasync for UNIX
sdasync should be implemented for linux and mac, at least for jconsole.
In principle, J has a main event loop. It waits for something to happen then responds to that. In principle, this main event loop is the right place to use poll() -- or perhaps select() if older systems are being supported -- and each open file descriptor has an associated handler. It shouldn't be that much more effort to arrange so that user code could register a locale's socket_handler in association with a file descriptor.
It's very convient to be able to service sockets without losing the ability to interact with the J session.
-- Raul Miller 2006-03-18 18:17:43
wd tooltips
I'd like to see the wd driver support tooltips for arbitrary controls.
I'd also like to see the form editor incorporate tooltips explaining the meaning of each of the terse words it presents (or, at minimum, I'd like to see tooltip support be general enough that this documentation could be provided by an energetic user).
Update: I was reminded that the status bar can be used for this purpose in most cases. This would be adequate for my immediate needs, though verbose, if I could get mouse enter/leave events for arbitrary controls.
-- Raul Miller 2006-03-25 03:30:58
wd to support more events
J wd should support handling more events from controls. At minimum on- enter/leave/change events should become accessible, ideally all events available in the system. -- AndrewNikitin 2006-04-20 02:07:14
session executed lines
In Session Manager, an executed line is such on which the user pressed Enter when it was the last line. As a result, it was executed, and may contain output just below it up to the next executed line.
It is proposed that Session Manager keep track of executed lines in a bit or index array. The advantages are: (1) they could be highlighted to easily distinguish from output code, similar to the lab entries; (2) a new key combination can be added, such as Alt+Enter, with the effect of re-running a possibly edited line, and replacing its old output with the result of the recent execution.
This simple design will enable the concept of a workbook, that is ability to control the ever scrolling session from filling itself with transitional code and constant manual deleting and copying to yield a tidy version of a session.
There are a couple of additional observations: the session manager will need to maintain the lines array, that is respond to text insertions and deletions, but that should be possible. Also it would make sense to have a resumable format for the session log other than plain text, but that could be simply a special character prefix at every executable line, such as inverted middle box drawing character ┤ (-|) .
Further, useful features can be easily added, e.g. marking/unmarking lines as executed and pressing another combination, such as Alt+Shift+Enter to run all surrounding executed lines, which will allow easy in-place explicit definitions. There would be no need for two windows: one for script and one for session -- good for small but illustrative examples such as casual problem solving, which make up most of code samples in J forums.
-- OlegKobchenko 2006-04-24 22:52:42
Input Log leading spaces
As it was said in this thread, it is an issue to have to enter back the leading spaces discarded by the Input Log. To fix, the following can be removed in jadefull.ijs
log=. < @ dltb ;._2 log
With spaces preserved, the Input Log looks better: more like the session manager, and the margin makes entries easier to read.
-- OlegKobchenko 2006-05-11 11:23:38
I meant Input Log is correct, but wd 'sminputlog' has 3 extra spaces. -- BillLam 2012-05-25 06:37:56
Alternatively, the spaces could be inserted on pasting -- this will remove duplicates congruent on spaces:
smprompt_jijs_ ' ', y pick log -- OlegKobchenko 2006-05-11 21:27:23
fixed in j601a. -- OlegKobchenko 2006-10-02 00:30:20
mechanism to detect mapped name
Please add a mechanism to determine whether a given noun is mapped. It is often important to know in order to take advantage of special code. For example, the definition of charsub in 'strings' is: {{{ charsub =. 4 : 0
- 'f t'=. |: _2 ]\ x l=. f i."1 0 y x=. l { t,'?' c=. l = #f c } x ,: y
)}}} Compare that to:
charsub2 =: 4 : 0
'f t'=. |: _2 ]\ x
l=. f i."1 0 y
x=. l { t,'?'
c=. l = #f
y=. c } x ,: y
)which is precisely equivalent except in the case of a mapped argument. But, since name =. name boolean } data ,: name is more optimized than simply name boolean } data ,: name, the former takes takes less than half the time and space of the latter:
n =: 'abc' {~ ? 600 600 $ 3
A =: 1000 ts '''abcdefgh'' charsub n'
B =: 1000 ts '''abcdefgh'' charsub2 n'
(a:,'no =.';'with =.'),.(;:'time space factor'), <"> A,. B,. A%B
+-------+---------+---------+-------+
| |time |space |factor |
+-------+---------+---------+-------+
|no =.|0.0331414|0.0147163|2.25203|
+-------+---------+---------+-------+
|with =.|9.96416e6|4.72096e6|2.11062|
+-------+---------+---------+-------+If we had some way of knowing whether the argument were mapped, we could take advantage of this difference in the case it is safe to do so:
charsub3 =: 4 : 0
'f t'=. |: _2 ]\ x
l=. f i."1 0 y
x=. l { t,'?'
c=. l = #f
if. ISMAPPED y do.
c } x ,: y
else.
NB. Argument not mapped, OK to overwrite y and
NB. take advantage of special code
y =. c } x ,: y
end.
). So far I have been unable to use the definitions in 'jmf' to write this utility myself.
-- DanBron 2006-09-27 16:49:19
Easy Reference to the Directory of a Script File
This is a proposal for a new verb to be added to the stdlib.
When constructing an application in J, one which requires more than one file, all the files defining the application are usually placed into one directory. It really doesn`t matter where that directory is. Just so they are all in the same directory. Except that J has no simple tool to find that directory.
This means that the application must supply the path to other files when loading additional scripts or data. In other words, a group of scripts is not movable to another directory without modification.
This is a proposal to add a verb like "spath" defined below to provide such a facility. Say that an application requires to load another script of the same application. Adding spath to the load or require in a script would find another script from the same directory as itself. Like:
load spath 'script2.ijs'
I ran into problems with trying to run Oleg`s "dtreeview". The script has several requires of additional scripts but all are in the same directory as "dtreeview". And it is required that that directory be 'user\classes\ole\'. "dtreeview" assumes that its scripts reside in 'user\classes\ole\' and that the current directory for J is where 'user\' resides.
I try to keep things that I get from outside sources separate from my stuff. I wanted to keep only my class definitions in 'user\classes\'. Well, when I fixed dtreeview it still failed because I didn`t have the ocx it required. But it prompted me to come up with the verb "spath" to make refering to the path where a script file is kept easy.
I called it "spath" for "script path". This may not be a very good name. But the concept of "spath" should aid in giving more portability to where applications are kept.
I changed the following in my copy of "dtreeview":
Original code
require'user\classes\ole\CImageList.ijs' require'user\classes\ole\CTreeView.ijs'
Changed to
require spath 'CImageList.ijs' require spath 'CTreeView.ijs'
Other required scripts were changed similarly.
The definition of spath
NB.*spath - Construct directory path for the script being executed
NB. Makes it easier to move groups of scripts around
NB. Argument:
NB. y - A file name to append to the path.
NB. Return:
NB. The file name from y with the full path preceeding it.
NB. This verb will work within a script file only.
NB. If used outside a script it will return numeric _1.
spath_z_=: 3 : 0
z=.''
if. _1-:z=.4!:4<'z' do. z return. end.
jpath_z_ y,~PATHSEP_j_(''"_)`([,~i:~{.])@.e.;z{4!:3''
)Discussion on this request moved to spath discussion. Please subscribe to that page to follow the discussion.
-- DonGuinn 2006-10-14 14:31:36
Enhancement to csv.ijs
In the packages/files/csv.ijs script, please consider refactoring the verb writecsv to separate the creation of the csv string and the writing of the file to disk. Something similar to this:
NB. ========================================================= NB.*makecsv v takes boxed array and creates csv string makecsv=: 3 : 0 dat=. ,each 8!:2 each y f=. '"'&,@(,&'",')@(#~ >:@(=&'"')) dat=. f each dat f=. <@(,&LF)@}:@; dat=. ;f"1 dat ) NB. ========================================================= NB.*writecsv v writes a boxed array to a csv file writecsv=: 4 : 0 dat=. makecsv x dat fwrites extcsv y )
This would mirror the structure of reading csv files and facilitate the addition of the following verb appendcsv.
NB. ========================================================= NB.*appendcsv v appends a boxed array to a csv file appendcsv=: 4 : 0 dat=. makecsv x dat fappends extcsv y )
-- RicSherlock 2007-05-31 11:40:07
Enhancement to verb dstat
The dstat verb in the packages/stats/statfns.ijs will currently only summarise a 1 dimensional list.
NB. ========================================================= NB. descriptive statistics dstat=: 3 : 0 t=. '/sample size/minimum/maximum/median/mean' t=. t,'/std devn/skewness/kurtosis' t=. ,&': ' ;._1 t v=. $,min,max,median,mean,stddev,skewness,kurtosis t,. ": ,. v y ) dstat 12$12?.@$0 sample size: 12 minimum: 0.103530598944 maximum: 0.842577815915 median: 0.440528129185 mean: 0.488322187264 std devn: 0.233509643496 skewness: _0.0511884674309 kurtosis: 1.86563664372 dstat 2 12$24?.@$0 |length error: dstat | t ,.":,.v y
Please consider updating it to handle at least the 2 dimensional case. e.g. the following changes will enable it to handle 2 (or more?) dimensions.
dstatnew=: 3 : 0 t=. '/sample size/minimum/maximum/median/mean' t=. t,'/std devn/skewness/kurtosis' t=. ,&': ' ;._1 t v=. # , min,max,median,mean,stddev,skewness , kurtosis t,. ": ,. |:v"1 y ) dstatnew 12$12?.@$0 sample size: 12 minimum: 0.103530598944 maximum: 0.842577815915 median: 0.440528129185 mean: 0.488322187264 std devn: 0.233509643496 skewness: _0.0511884674309 kurtosis: 1.86563664372 dstatnew 2 12$24?.@$0 sample size: 12 12 minimum: 0.103530598944 0.0243426529173 maximum: 0.842577815915 0.94306021392 median: 0.440528129185 0.433765550397 mean: 0.488322187264 0.415075199997 std devn: 0.233509643496 0.293523186694 skewness: _0.0511884674309 0.292150865694 kurtosis: 1.86563664372 1.88530129019
-- -- RicSherlock 2007-06-27 03:21:32
'trace' should warn about special variables
The jtrace facility should issue a warning if any of the argument tokens (;:'m n u v x y') appears in an expression for trace (or parens).
Behavior of these variables can be non-intuitive for some users and these names are a poor choice where they do not correspond to relevant arguments. Users who should be encouraged to use different names in this context.
-- Raul Miller 2007-07-02 17:14:03
Library categories for Project Manager
Please consider enhancing Project Manager to split up the Libraries in to 3 categories:
- system libraries - provided by JSoftware with J.
- addon libraries - available via Package Manager
- user libraries - written by the J developer/user
Mockup of Library tab.
Some way of working out the category of your selected libraries would be useful. In the mockup I've made 3 separate listboxes, but could just use a different suffix or prefix (similar to how development-only libraries are currently denoted).
Benefits of the enhancement.
- enable the user to find the desired library more easily (better than one big long list with the different categories intermingled).
- gives the user some idea of how robust the library might be (self-built probably not as reliable as Jsoftware-distributed).
- potentially allow differentiation, based on source, of which scripts are included vs. required in the final built script.
Mockup image of Build options.
Making the enhancement in such a way that currently-defined project *.ijp files are still valid would be ideal. One potential way of doing this is to leave the PUBLIC_j_ and PRIMARYLIBS nouns as is, and determine the category of the library script from its location. Scripts located in ~system/... are system libraries. Scripts located in ~addons/... are addon libraries. Scripts not in either of those locations are user libraries.
-- RicSherlock 2007-09-18 01:34:17
Addon scripts available in Project Manager
Related to, but not dependent on the previous request. Addons installed via Package Manager could be automatically made available in the Project Manager Library tab.
One way (perhaps not the best) would be for Package Manager could manage the addition and deletion of Addon scripts to the PUBLIC_j_ as it installs/removes addons from the local repository.
-- RicSherlock 2007-09-18 01:44:12
Simplify setting up multiple users for J
Modify profile.ijs to use the directory in which the config.ijs script resides for the value of "hom" instead of using the value of INSTALLFOLDER or HOME. And change the definitions for usr and tmp to be "hom,'\user'" and "hom,'\temp'".
The benefit is that no modification would be required to profile.ijs to support multiple users. As for compatibility, if profile.ijs is run from the INSTALLFOLDER directory then it would still work as it does now. Since the user is not required to make any changes to profile.ijs, only copy it, the likelyhood of J failing to start is reduced.
For one to set up a user outside of the default of in INSTALLFOLDER simply:
0. Create the directory which will contain the other user's user and temp directories
1. Copy profile.ijs to that directory
2. In Windows, Create a shortcut to the j executable and add the following after the path to the J executable file name (Target:)
-jprofile <user directory>\profile.ijs
For UNIX etc. there should be a similar tool; however, I am not that fimilar with systems other than Windows.
The actual changes to profile.ijs would be: replace the line defining hom with
hom=.PATHSEP_j_(i:~{.]);(4!:4<'mkdir'){4!:3''and the lines for usr and tmp to
tmp=. hom,'\temp' usr=. hom,'\user'
This makes no assumptions as to the value of the current directory (Start In:) allowing users to define it any way they want.
DonGuinn 2007-11-02 16:16:30
Consistent interface to fappends and fwrites
As described in this forum post, the fwrites verb in the files script accepts numeric data while fappends does not. This behaviour should be consistent across both verbs.
-- RicSherlock 2008-08-13 23:58:26
Addition of namedoc
A facility similar in functionality to the verb namedoc described here, would be a useful addition to the standard profile. The verb arose as a result of this forum thread.
namedoc 'fread'
fread (v) read file
y is filename {;start size}
x is optional:
= b read as boxed vector
= m read as matrix
= s read as string (same as freads)
namedoc 'namedoc'
namedoc (v) scriptdoc for a name
e.g. namedoc 'namedoc'
namedoc 'split'
;(namedoc,LF"_,LF"_) &.> _3{.nl_z_''-- RicSherlock 2008-08-14 00:14:19
An assortment of notes on Application Distribution and Project Manager
I recently built a project in Project Manager and set it up for distribution with the Application Distribution - Installer templates. In the end, it worked fine, but I had some bumps along the road.
I ran the Studio/Application Distribution - Installer lab (and discovered that ESC no longer will terminate a Plot window in Windows, at least.) I was impressed with the process. It was much smoother than my experience with the pure Project Manager approach.
I was familiar with building a standalone application with Project Manager, so I set up my library entries and set up the build options to include everything. I later discovered this wasn't needed and I could keep the libraries as requires.
I also set up a target .ijl file. This seemed to work. However, the .ijl file created by Project Manager would not load into J. I had to add a postbuild step to read the .ijs, lock it and save the .ijl. This file loaded into J.
I also tried setting APP_LOCK=: 1 in the Installer script to lock the scripts, but it didn't seem to do anything.
I tried adding ADDON scripts to the APP_ADDONS definition, but this resulted in an error, since allowedpaths did not include ~addons\.
I also noticed that ~system\extras\labs\* was included in the APP_SYSTEM_COMMON definition. I updated this to remove the labs and it reduced the size of the final exe by 20% or so.
The final result was worth the effort. The .exe installed simply and the new application runs without any problems.
The application depends on a Virtual Grid. Thanks to J team for this very useful tool. It made browsing a large data file where each line requires significant effort to format very fast and easy to program.
-- DavidMitchell 2008-11-04 21:35:24
