Author Topic: Variable names with "#", "$" etc. Where does this come from?  (Read 4488 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Variable names with "#", "$" etc. Where does this come from?
« on: October 30, 2010, 05:49:32 AM »
I have seen quite a few lisp examples where variable names contain a certain character to indicate the value type. For instance "#" indicates a variable that is used to store an integer, and "$" is used for string variables. Where does this come from?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #1 on: October 30, 2010, 06:24:17 AM »

From people who didn't know how to use descriptive names and had no sense on aesthetics  :-P
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #2 on: October 30, 2010, 06:42:08 AM »
Surely it's also bad practice as, if you decide to migrate to another API there's a good chance those characters aren't valid variable names...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #3 on: October 30, 2010, 08:55:09 AM »
I guess for purest it's like a stick in the eye. :evil:
I have seen some authors recommending this technique and thought at the time it was a good one but
gave it up in short order. For me the descriptive names worked better. The longer names ware me out typing
because I'm a four finger and two thumbs typist with the second worst spelling habits. So shorter names
get used now but I do try to keep them descriptive.
« Last Edit: October 30, 2010, 09:31:16 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #4 on: October 30, 2010, 09:12:36 AM »
I must admit, I do get lazy with variable names, for example, I used to represent an entity name with 'ent', over time this became 'en', and now its usually just 'e'.  :|

Aerdvark

  • Guest
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #5 on: October 30, 2010, 09:44:52 AM »
I tend to be "not lazy" and use too long variablenames like "OldSystemVariables" or "NewInsertionPoint".
When making these two "OSV" or "NIP" I always end up with commenting it out:

(setq OSV ... ;_OldSystemVariables
NIP ... ;_NewInsertionPoint

Now the question rises why I use the underscore...?
I don't know, I sure did copy the idea from other lispers.

At one point I did concider the option to use $ for string variables but then there are so many variables that need a symbol.
$ for string, # for integer, % for real??, etc.

My 2 cents..

mkweaver

  • Bull Frog
  • Posts: 352
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #6 on: October 30, 2010, 10:13:22 AM »
"$" to indicate a string variable comes from GW Basic - http://en.wikipedia.org/wiki/GW-BASIC

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #7 on: October 30, 2010, 10:22:54 AM »
I'm pretty sure that some programming languages required it (but can't remember any specifics).

Think it may have been recommended for BASIC, but that could just have been a dodgy memory!

dJE
===
dJE

Aerdvark

  • Guest
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #8 on: October 31, 2010, 01:42:22 PM »
"$" to indicate a string variable comes from GW Basic - http://en.wikipedia.org/wiki/GW-BASIC
This reminded me of the Commodore 64 era....

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #9 on: November 01, 2010, 03:30:15 AM »
heh ... I typed a whole lotta keys while looking at that screen ... oh, the early 80s .. glad they are gone now ;-)

Now as far as the variables are concerned, I don't use things like $ or # in variable names, however, what I will do is use a prefix on my variables that indicate their type, for integers I might use a variable like intOffset, if for no other reason than to differentiate it from dblOffset ... I know I could make the names more descriptive, but I tire easily when I have really long descriptors.

Just wait till you get one of those files that use really wierd variable names .. like it is going to stop a knowledgable person from understanding the code. I've seen some real winners ..
Code: [Select]
(defun *wer$r (redewd) (princ redewd))

I mean seriously, who does that kind of crap anyway?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #10 on: November 01, 2010, 04:39:18 PM »
Just wait till you get one of those files that use really wierd variable names .. like it is going to stop a knowledgable person from understanding the code. I've seen some real winners ..
Code: [Select]
(defun *wer$r (redewd) (princ redewd))

I mean seriously, who does that kind of crap anyway?

If ITwit/office manager wrote code, all the variables would names in Latin or my favorite, the names of Greek Gods.  When I hired on he had all the computers named names of the gods and demi-gods.  Yeah after my begging did not I had to threaten him with bodily harm.  :pissed:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #11 on: November 02, 2010, 09:13:13 AM »
I have seen quite a few lisp examples where variable names contain a certain character to indicate the value type. For instance "#" indicates a variable that is used to store an integer, and "$" is used for string variables. Where does this come from?
Most likely from encryption programs.  Convert.exe comes to mind.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #12 on: November 03, 2010, 04:40:30 AM »
Thanks everybody for sharing your thoughts on this subject. I had the idea that this "convention" came from some other lisp dialect. Apparently not.

I disagree with Lee's comment about migrating. If you have to port a lisp routine to, let's say, some C-language, the variable names would be the least of your worries. Your biggest problem would be translating all the LISt Processing :wink:. But I know very, very little about C-languages.

As far as aesthetics are concerned, I only object to code that goes for a "kelvinated" look:
Code: [Select]
(defun c:XYZ ( /  A B C D E F G H)
....

I agree with CAB and Aerdvark and try to use short but clear names. In Aerdvark's example: OldSystemVariables or OSV, I would use oldSysVars.

<EDIT: typo>
« Last Edit: November 03, 2010, 10:29:15 AM by roy_043 »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #13 on: November 03, 2010, 04:45:46 AM »
As an example, here is a link to some lisp code by Terry Miller who uses this convention.
http://web2.airmail.net/terrycad/AutoLISP-Code.htm

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Variable names with "#", "$" etc. Where does this come from?
« Reply #14 on: November 03, 2010, 09:23:52 AM »
I disagree with Lee's comment about migrating. If you have to port a lisp routine to, let's say, some C-language, the variable names would be the least of your worries.

Perhaps, but why add the problems...