Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

not so pseudo code? (an alternative to style changes)

 [1/7] from: brett:codeconscious at: 9-Jan-2002 23:00


While reading the style threads I visualised a rather strange method of communicating the meaning of a Rebol program. So the idea is this, imagine a function you have written - it should be non-trivial perhaps with at least a loop and a condition maybe a few, what the heck, make it at least 20 lines long. Now imagine you are looking at the source using an enhanced viewer. What if you could name (or comment) a given code block (I know we can but just bear with me). Now the trick is that if you magic-click the code-block it collapses into it's associated name (or short description). So visually your function is now far simpler yet still only one function. This is essentially what I do in my mind when trying to understand other people's code (more accurately I tend to mentally group sections of code). I thought though a block was a convienient unit of grouping for a Rebol tool. Someone might say "it should be a function anyhow". I'd respond that it could and perhaps this enhanced viewer might suggest such a refactoring. So it has an active use as well as a documentry / learning use. So I guess I'm saying that code in an enhanced viewr could have an comment or name attribute attached that can be visually very helpful. We have GUIs why do we keep commenting our code in syntax?! We should comment the code values themselves! Can someone write me one please? I'd like it yesterday thanks! :) Brett.

 [2/7] from: hallvard:ystad:helpinhand at: 9-Jan-2002 13:16


Brett, With the risk of having completely misunderstood what you are asking for... I believe JEdit has the capacity to collapse portions of code, so that if you have, say collapse: func [a b /local c] [ print "this method does nothing." loop 20 [ print "I do nothing!" ] comment { This could have been longer, but this should do. } ] You could double-click the word collapse, and the only thing you would see was collapse: func [a b /local c] [ ... ] I don't use JEdit myself, so I'm not 100% sure how this works, but I believe JEdit is free, so you could always check it out for yourself. This is a feature I've wanted in TextPad for a long time, though. ~H Dixit Brett Handley (13.00 09.01.2002):

 [3/7] from: brett:codeconscious at: 9-Jan-2002 23:31


Hi Hallvard, Thanks for your message. Instead of collapse: func [a b /local c] [ ... ] something like this: collapse: func [a b /local c] print-msg-then-useless-stuff-20-times or collapse: func [a b /local c] [ print "this method does nothing." loop 20 print-nothing comment { This could have been longer, but this should do. } ] Brett.

 [4/7] from: chris:starforge:demon at: 9-Jan-2002 13:01


Brett Handley wrote:
> Now imagine you are looking at the source using an enhanced viewer. What if > you could name (or comment) a given code block (I know we can but just bear > with me). Now the trick is that if you magic-click the code-block it > collapses into it's associated name (or short description). So visually your > function is now far simpler yet still only one function.
Not REBOL but.... When I'm coding C/C++ I use emacs (death to vi!) which has a minor mode called Hide-Show. Using that I can do things like (pulling some code from a recent project): /** Voltage chart text formatter. * This replaces special "$" codes in the specified format string with * values taken from upsStatus. Please see the switch in the body of the * function for details about which codes are recognised. All unrecognised * codes or other characters are simply copied to the buffer. * * \par Arguments: * \arg \c buffer - Destination buffer. * \arg \c size - number of characters available in buffer (not inc \n). * \arg \c format - Format string to process into buffer. * * \todo Find a way to unify formatVoltText(), formatFreqText() and * formatTempText() to reduce the amount of replication between them (maybe * use varargs and pass the values to replace code with in that way?) */ static void formatVoltText(gchar *buffer, gint size, gchar *format)... If I then shift-middleclick on the function name I can show the body of the function, a shift-middleclick in the function body reduces it to the function name and parameter list followed by "..." again. Is this what you mean? Chris -- .------{ http://www.starforge.co.uk }-----. .--------------------------. =[ Explorer2260, Designer and Coder \=\ P: TexMaker, ROACH, site \ =[___You_will_obey_your_corporate_masters___]==[ Stack: EETmTmTRRSS------ ]

 [5/7] from: nitsch-lists:netcologne at: 9-Jan-2002 22:12


RE: [REBOL] not so pseudo code? (an alternative to style changes) [brett--codeconscious--com] wrote:
> While reading the style threads I visualised a rather strange method of > communicating the meaning of a Rebol program.
<<quoted lines omitted: 17>>
> should comment the code values themselves! > Can someone write me one please? I'd like it yesterday thanks! :)
yesterday? thats easy. then there was oberon system v4. :)
> Brett. >
-Volker

 [6/7] from: greggirwin:mindspring at: 10-Jan-2002 12:45


Hi Brett, UserLand Frontier is based on an outline idiom. You can collapse things so all subordinate items are hidden, whether it's a function body, a loop body, etc. You can't name the items, AFAIK, but I can see where, in REBOL, if you have a word whose value is set via an inline assignment, it could work. You would just collapse to the word itself. Might be kind of tricky to come up with rules and behavior that work well, but that's why we do this stuff, right? :) --Gregg

 [7/7] from: brett:codeconscious at: 11-Jan-2002 17:42


> You can't name the items, AFAIK, but I can see where, in REBOL, if you
have
> a word whose value is set via an inline assignment, it could work. You
would
> just collapse to the word itself. Might be kind of tricky to come up with > rules and behavior that work well, but that's why we do this stuff, right? > :)
Possibly :) I think your idea is good. Add to that an object which redefines each of those inline words to a comment/annotation. Interesting. :) Brett.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted