Here's a program that I rewrite whenever I take
up a new language. The output of the Windows PATH command is
often quite difficult to read, and I write a little utility to
parse the output into individual lines. I have about a dozen
variations of this in Perl, Ruby, Forth, Python, ooRexx, etc.
Here is the NetRexx version:
/* */ thePath = System.getenv("PATH") loop while thePath \= "" parse thePath dir ";" thePath say dir end Similar techniques work just as well for setting environment variables. Naturally, this code isn't as portable as it might be ... but it works under Windows XP and Cygwin, and that's all I need. Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 10 November 2010 15:38, Tom Maynard <[hidden email]> wrote:
I have similar Windows batch and bash shell scripts to do much the same thing. Can't live without them... I would suggest the following modifications to make it work seamlessly on Windows and on UNIX/Linux/Cygwin/Mac OS X systems though: /* */ ps = System.getProperty("path.separator") thePath = System.getenv("PATH") loop while thePath \= "" parse thePath dir (ps) thePath say dir end Just for laughs; here's a Java version: class echoEnv { public static void main(String[] args) { String ps = System.getProperty("path.separator"); String thePath = System.getenv("PATH"); String [] pathEmlts = thePath.split(ps); for (String elmt : pathEmlts) { System.out.println(elmt); } } } In the interests of full disclosure; here's my Windows Batch program (echoEnv.cmd) that dose mostly the same thing (it does handle other environment variables so I can look at CLASSPATH etc. too): @echo off @setlocal @if ".%*" EQU "." ( @set ENVPATH=%PATH% ) else ( @set ENVPATH=%* ) @set /A IDX=0 @set SP="" :LoopTop @if not defined ENVPATH @goto EndLoop @set /A IDX=%IDX% + 1 @if %IDX% LSS 10 ( @set IDXT=0%IDX% ) else ( @set IDXT=%IDX% ) for /F "tokens=1* delims=;" %%i in ("%ENVPATH%") do ( @if "/%%i" NEQ "/" ( @set DIT=%%i ) else ( @set DIT=%SP% ) @set ENVPATH=%%j ) @echo %IDXT%: %DIT% @goto LoopTop :EndLoop @endlocal and a bash shell script for UNIX/Linux/Cygwin/Mac OS X etc. #!/bin/bash # ------------------------------------------------------------------------------ # # __.____1____.____2____.____3____.____4____.____5____.____6____.____7____.____8 function echoEnv { local envv local dir local saveIFS="$IFS" local xpath if [ ! -z "$1" ] then envv=$1 else envv="PATH" fi eval xpath=\$$envv if [ ! -z "$xpath" ] then if [ -z "$2" ] then IFS=':' else IFS="$2" fi for val in $xpath do echo "$val" done IFS="$saveIFS" fi } export echoEnv I source this file from my .bashrc initialization file so it gets built into my environment to make it available every time I open a shell session, hence the function and export statements. Alan. Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email]
Alan
-- Needs more cowbell. |
In reply to this post by Tom Maynard
This on-going exercise nudged me back to MFC's introduction to NetRexx 2 of 22 May 2009 ( page 13 in my offprint). In a section "Dealing with reality" is the definition of Astonishment Factor: "If a feature, accidentally misused, gives apparently unpredictable results, then it has a high Astonishment Factor and is therefore undesirable."
Thanks for the help; Enjoy the Day. Bob Hamilton Richardson, Texas _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by alansam
On 11/11/2010 2:20 AM, Alan Sampson wrote:
I think all of those clearly display the beauty and simplicity of the NetRexx version (six lines of code!). It can be done in fewer (Groovy): Process p = "cmd /c path".execute() p.text.tokenize(";").each { entry -> println entry } But without the clarity, IMO. I admit, I may be expressing my own bias. [Note the curly brackets.] Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
On Thu, Nov 11, 2010 at 4:45 PM, Tom Maynard <[hidden email]> wrote:
> Process p = "cmd /c path".execute() > p.text.tokenize(";").each { entry -> println entry } > > But without the clarity, IMO. I admit, I may be expressing my own bias. > [Note the curly brackets.] > Tom. What is with new languages and curly brackets? I hate them. I see those in JavaFX and my head begins to spin in a 360-degree full circle... not to mention having to type them myself... FC _______________________________________________ Ibm-netrexx mailing list [hidden email] |
I'm baffled by the emotional response braces ("curly brackets") generate. Also, some people here call them "special characters". They don't seem to be any more special than (), [], or <> which are also ASCII characters. Please explain.
Let me hasten to add that I am not, and have never been, a member of the Curly Brackets Party. On Thu, Nov 11, 2010 at 3:51 PM, Fernando Cassia <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 11/11/2010 3:14 PM, George Hovey wrote:
I'm baffled by the emotional response braces ("curly brackets") generate. Also, some people here call them "special characters". They don't seem to be any more special than (), [], or <> which are also ASCII characters. Please explain.Firstly, at least on a standard 101-key keyboard (American) they are shifted, each requiring then two keys to be pressed. Secondly, they are (on the same keyboard) somewhat awkwardly located for the touch typist and are easily missed. They are also difficult to differentiate visually from regular parentheses (with my aging eyes). And then, why have them at all? They're just "punctuation noise" and perform no useful function. NetRexx doesn't use them, and NetRexx is "human-friendly." By simple logical extension: curly brackets are human-unfriendly. Purely personal opinion, of course. Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by George Hovey-2
On Thu, Nov 11, 2010 at 6:14 PM, George Hovey <[hidden email]> wrote:
> I'm baffled by the emotional response braces ("curly brackets") generate. > Also, some people here call them "special characters". They don't seem to > be any more special than (), [], or <> which are also ASCII characters. > Please explain. http://philikon.wordpress.com/2010/01/15/javascript-curly-braces-are-not-the-problem/ "JavaScript has picked up lots of pythonisms over the last few years which is obvioulsy a Good Thing(tm). Aza Raskin of Mozilla has now created Pyscript, a version of JavaScript sans curly braces. As a fellow Pythonista I too find curly braces aesthetically unpleasant" http://stackoverflow.com/questions/633497/java-switch-cases-with-or-without-braces "Sensible whitespace == nice. Unnecessary braces == suck. – Shog9 Mar 11 '09 at 6:48" JavaFX: Curly brace overdose http://refactorama.blogspot.com/2008/05/javafx-curly-brace-overdose.html "Have you seen code examples from JavaFX script? The language is very interesting. It contains many new features that may revolutionize the way people create user interfaces in Swing, such as triggers and binding. But one thing that always bothers me about the code examples that I have seen is the insane amount of curly braces that they have to use. (code snippet) Wow... that code looks like a tower. " FC > Let me hasten to add that I am not, and have never been, a member of the > Curly Brackets Party. > > On Thu, Nov 11, 2010 at 3:51 PM, Fernando Cassia <[hidden email]> wrote: >> >> On Thu, Nov 11, 2010 at 4:45 PM, Tom Maynard <[hidden email]> wrote: >> > Process p = "cmd /c path".execute() >> > p.text.tokenize(";").each { entry -> println entry } >> > >> > But without the clarity, IMO. I admit, I may be expressing my own bias. >> > [Note the curly brackets.] >> > Tom. >> >> What is with new languages and curly brackets? I hate them. I see >> those in JavaFX and my head begins to spin in a 360-degree full >> circle... not to mention having to type them myself... >> >> FC >> >> _______________________________________________ >> Ibm-netrexx mailing list >> [hidden email] >> > > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > > -- "It begins with a blessing And it ends with a curse; Making life easy, By making it worse;" -- Kevin Ayers _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Tom Maynard
On Thu, Nov 11, 2010 at 6:37 PM, Tom Maynard <[hidden email]> wrote:
> On 11/11/2010 3:14 PM, George Hovey wrote: > > I'm baffled by the emotional response braces ("curly brackets") generate. > Also, some people here call them "special characters". They don't seem to > be any more special than (), [], or <> which are also ASCII characters. > Please explain. > > Firstly, at least on a standard 101-key keyboard (American) they are > shifted, each requiring then two keys to be pressed. Secondly, they are (on > the same keyboard) somewhat awkwardly located for the touch typist and are > easily missed. They are also difficult to differentiate visually from > regular parentheses (with my aging eyes). > > And then, why have them at all? They're just "punctuation noise" and > perform no useful function. NetRexx doesn't use them, and NetRexx is > "human-friendly." By simple logical extension: curly brackets are > human-unfriendly. Exactly. Parentheses are familiar from simple math, as in a=b+(c*2) Curly braces reminds me of algebra http://en.wikipedia.org/wiki/Bracket_(mathematics) As such, I find them useful only when defining some complex math calculation, not to be inserted seemingly randomly throughout text that shuld "make sense". Look at the ugly JavaFX curly braces overdose article I included in my previous reply... And then there´s the issue of having to press two keys to get them. On Spanish layout keyboards (which are definitely programmer-hostile, with common characters like the backslash \ or the brackets [] requiring the use of the "AltGr" key) that is specially annoying. FC _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Tom Maynard
On Thu, Nov 11, 2010 at 6:37 PM, Tom Maynard <[hidden email]> wrote:
> And then, why have them at all? They're just "punctuation noise" and > perform no useful function. NetRexx doesn't use them, and NetRexx is > "human-friendly." By simple logical extension: curly brackets are > human-unfriendly. > > Purely personal opinion, of course. > Tom. Hey, I´d vote for you. FC _______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 11/11/2010 4:11 PM, Fernando Cassia wrote:
> Hey, I´d vote for you. To paraphrase Gen'l Sherman, if nominated I will not run, if elected I will not serve. <g> Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Fernando Cassia-2
not to mention that they never were on any 3270 keyboard that I have
used and have given rise to the most horrible construct in C ever, the ??<trigraph??> (these are the ones for curly braces) There is, by the way, some history in the elimination of 'punctuation' in NetRexx, so while I am not sharing the emotions an sich, I am not very surprised about them and must conclude that over-punctuation-abhorrence is a given in the NetRexx universe. best regards, René On Thu, Nov 11, 2010 at 11:11 PM, Fernando Cassia <[hidden email]> wrote: > On Thu, Nov 11, 2010 at 6:37 PM, Tom Maynard <[hidden email]> wrote: > >> And then, why have them at all? They're just "punctuation noise" and >> perform no useful function. NetRexx doesn't use them, and NetRexx is >> "human-friendly." By simple logical extension: curly brackets are >> human-unfriendly. >> >> Purely personal opinion, of course. >> Tom. > > Hey, I´d vote for you. > > FC > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > _______________________________________________ Ibm-netrexx mailing list [hidden email] |
That was cathartic! Consider me up to speed on curly brackets.
On Thu, Nov 11, 2010 at 5:34 PM, René Jansen <[hidden email]> wrote: not to mention that they never were on any 3270 keyboard that I have _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by George Hovey-2
Good to hear you are not a member of the nefarious Curly Brackets
Party, George! ;-)
My own reason for hating them is that in typical Java use they are paired vertically, often several of them on successive lines all by themselves, and I find it impossible to match them with their partner by eyeball in spite of the obvious intention that I do so. It is an incredible waste of space and a generally unneeded one since NetRexx shows that you can start and end methods and classes without them. And "do ... end" is so much easier for the eye to parse for other code blocks... On 11/11/2010 1:14 PM, George Hovey wrote: I'm baffled by the emotional response braces ("curly brackets") generate. Also, some people here call them "special characters". They don't seem to be any more special than (), [], or <> which are also ASCII characters. Please explain. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Kermit,
The one (small) fly in the ointment is that jEdit has a superb facility for graphically indicating matching of parens, brackets and braces which, unfortunately, doesn't work with Do...End. In a previous incarnation as a C programmer I found this quite helpful. In NetRexx, with nested blocks of any complexity I find myself religiously using labels (not necessarily a bad thing) in order to get more specific error diagnostics. On Thu, Nov 11, 2010 at 8:22 PM, Kermit Kiser <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
I have to put in a plug for KEDIT for Windows here.
1) It uses "Kexx" (essentially full Rexx) as its scripting language, and 2) It color codes all of the matching levels of parens, brackets and braces AND Do...End, or any other pairs, definable by file type or on the fly. (Other syntax coloring as well.) Jeff (Old XEDIT guy) On 11/11/2010 9:15 PM, George Hovey wrote: > Kermit, > The one (small) fly in the ointment is that jEdit has a superb > facility for graphically indicating matching of parens, brackets and > braces which, unfortunately, doesn't work with Do...End. In a > previous incarnation as a C programmer I found this quite helpful. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Kermit Kiser
On Thu, Nov 11, 2010 at 10:22 PM, Kermit Kiser <[hidden email]> wrote:
PHP has deprecated curly braces as of PHP 6. ----- "String access and modification by character
Characters within strings may be accessed and modified by specifying the
zero-based offset of the desired character after the string
using square array-brackets like $str[42] so think of
a string as an array of characters. Note:
They may also be accessed using braces like $str{42}
for the same purpose. However, using square array-brackets is preferred
because the {braces} style is deprecated as of PHP 6." ----- http://www.nusphere.com/kb/phpmanual/language.types.string.htm? FC _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Kermit Kiser
On Thu, Nov 11, 2010 at 10:22 PM, Kermit Kiser <[hidden email]> wrote:
This is good stuff. Since this is a public mailing list... anybody has a problem if I turn this discussion (and quotes) into an article ranting against the over use of curly brackets, or braces in programming languages?. I´m asking just to be polite. ;) FC _______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 11/12/2010 2:53 AM, Fernando Cassia wrote:
> > Since this is a public mailing list... anybody has a problem if I turn > this discussion (and quotes) into an article ranting against the over > use of curly brackets, or braces in programming languages?. > > I´m asking just to be polite. ;) > I would only suggest changing the subject line ... as I have already done. This is only polite since not everyone may want to follow this new thread. Reply to this note and everyone will know where it came from (and whether or not they wish to read it). If it survives several iterations, simply change the subject to "Curly Brackets" and drop the "was". Tom _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Fernando Cassia-2
Hi Fernando, the question (as I see it) is what parenthesis, brackets, and curly braces are for: Let's assume, that in his wisdom, Mr Mike .F. Cowlishaw would have defined: "{" means start, begin, do, etc "}" meand end of the above Then, we might define: a = {1, 2, 3:5, 7 12} *and*, by using the equivalence definition that ":" is a SYNONYM to ".." (in this context. Pascal, authored by Nicolaus Wirth, ETH Zurich, for instance, did use the ".." as the separator.... Now, we can go ahead and define: Alphabeth = {a,b,c, ...} Note the usage of the ELLIPSIS (...) <grin> And the, suing the curly braces, we can define *enumerated* entities ... What do you think ? Thomas Schneider. ============================================================= Am 12.11.2010 09:53, schrieb Fernando Cassia:
--
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
Free forum by Nabble | Edit this page |