The `if' command

This is a discussion on The `if' command within the mumps forums in Programming Languages category; Naked references are bad - nude variables are encouraged. Figure that one out. 8^) Duke Normandin <dukeofperl @ ml1.net> wrote in news:lFaSj.3318$PM5.2947 @edtnps92: > Thanks for the great explanation! What is _your opinion_ of > "naked references" -- if you dare to go there....

Go Back   Application Development Forum > Programming Languages > mumps

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
Reply

 

LinkBack Thread Tools Display Modes
  #11  
Old 05-01-2008, 08:32 AM
Rilian
Guest
 
Default Re: The `if' command


Naked references are bad - nude variables are encouraged.

Figure that one out. 8^)


Duke Normandin <dukeofperl@ml1.net> wrote in news:lFaSj.3318$PM5.2947
@edtnps92:

> Thanks for the great explanation! What is _your opinion_ of
> "naked references" -- if you dare to go there.


Reply With Quote
  #12  
Old 05-01-2008, 08:01 PM
Duke Normandin
Guest
 
Default Re: The `if' command

On 2008-05-01, Maury Pepper <mpepper_scram_spam@ieee.org> wrote:
> "Duke Normandin" <dukeofperl@ml1.net> wrote in message
> news:0waSj.3316$PM5.2929@edtnps92...
>> On 2008-04-30, Rob Tweed <rtweed@mgateway.com> wrote:


[snip]

>>> daft invention and at worst just plain evil, and are to be avoided at
>>> all costs. Stick to explicit global references or you'll end up with
>>> an incomprehensible, unmaintainable mess. I'm sure someone somewhere
>>> will wade in with a wall of flame to extol their arcane virtues but
>>> I've never encountered a single situation in 28 years where they made
>>> any sense whatsoever.

>>
>> I believe you! Once I know what "naked references" are, I'll be in a
>> better position to judge for myself.
>> --
>> Duke Normandin

>
> See: http://71.174.62.16/Demo/AnnoStd "The prefix ^ uniquely denotes a
> global variable name. A global variable name is either unsubscripted or
> subscripted; if it is subscripted, any number of subscripts separated by
> commas is permitted. Except where otherwise specified, a subscript may not
> equal the empty string. An abbreviated form of subscripted gvn is permitted,
> called the naked reference, in which the prefix is present but the
> environment, name and an initial (possibly empty) sequence of subscripts is
> absent but implied by the value of the naked indicator. An unsubscripted
> occurrence of gvn may carry a different value from any subscripted
> occurrence of gvn."
>
> If, instead of using naked reference for my example, I had used a function
> with side-effects, it would probably have provoked a similar rant.


I read the above URL after spending 20 minutes looking for the appropriate
material. I must say that its fairly confusing to this Mumps noob. Would you
give me a comparative example, please. At any rate, I suspect that "naked
references" are something that I can live without for quite some time - is
that correct? TIA...
--
Duke Normandin
Reply With Quote
  #13  
Old 05-01-2008, 08:05 PM
Duke Normandin
Guest
 
Default Re: The `if' command

On 2008-05-01, Rilian <noway@nohow.com> wrote:
>
> Naked references are bad - nude variables are encouraged.
>
> Figure that one out. 8^)
>
>
> Duke Normandin <dukeofperl@ml1.net> wrote in news:lFaSj.3318$PM5.2947
> @edtnps92:
>
>> Thanks for the great explanation! What is _your opinion_ of
>> "naked references" -- if you dare to go there.

>


You've _got_ to be sh....ing me!!
--
Duke Normandin
Reply With Quote
  #14  
Old 05-01-2008, 08:47 PM
Pete
Guest
 
Default Re: The `if' command

On May 1, 5:05 pm, Duke Normandin <dukeofp...@ml1.net> wrote:
> On 2008-05-01, Rilian <no...@nohow.com> wrote:
>
>
>
> > Naked references are bad - nude variables are encouraged.

>
> > Figure that one out. 8^)

>
> > Duke Normandin <dukeofp...@ml1.net> wrote in news:lFaSj.3318$PM5.2947
> > @edtnps92:

>
> >> Thanks for the great explanation! What is _your opinion_ of
> >> "naked references" -- if you dare to go there.

>
> You've _got_ to be sh....ing me!!
> --
> Duke Normandin


He is....a little.

Here's a quick explainer:

SET ^Cars("pickup",1)="Tundra" --- * Full global reference *
SET ^(2)="Rabbit" --- * Naked global reference *
SET ^(3)="ChevyS10" --- * Assume subscript level 2 *
SET ^(3,1)="ChevyS104liter" --- * Go to subscript level 3 *
SET ^(2)="ChevyS106liter" --- * Assume subscript level 3 *

So a naked global reference is one where the fully qualified global
name "^Cars("pickup"," is implied and can be called with just the
caret and the subscript number. You can see how naked global
references are unnessecarily confusing because they don't "spell it
out" for the person reading the code. You've got to pick back through
in order to see what you're referencing and it drives me nuts.

Also, PG = Peanut Gallery = US. Or should I say THEM. I usually just
lurk here....

Reply With Quote
  #15  
Old 05-01-2008, 10:01 PM
Maury Pepper
Guest
 
Default Re: The `if' command


"Duke Normandin" <dukeofperl@ml1.net> wrote in message
news:TUsSj.3753$XI1.2105@edtnps91...
> On 2008-05-01, Rilian <noway@nohow.com> wrote:
>>
>> Naked references are bad - nude variables are encouraged.
>>
>> Figure that one out. 8^)
>>
>>
>> Duke Normandin <dukeofperl@ml1.net> wrote in news:lFaSj.3318$PM5.2947
>> @edtnps92:
>>
>>> Thanks for the great explanation! What is _your opinion_ of
>>> "naked references" -- if you dare to go there.

>>

>
> You've _got_ to be sh....ing me!!
> --
> Duke Normandin


Rilian was being punny. "nude" as in NEW'd. Check out the NEW command.

Reply With Quote
  #16  
Old 05-02-2008, 07:59 AM
Duke Normandin
Guest
 
Default Re: The `if' command

On 2008-05-02, Pete <peter.charbonnier@gmail.com> wrote:
> On May 1, 5:05 pm, Duke Normandin <dukeofp...@ml1.net> wrote:
>> On 2008-05-01, Rilian <no...@nohow.com> wrote:
>>
>>
>>
>> > Naked references are bad - nude variables are encouraged.

>>
>> > Figure that one out. 8^)

>>
>> > Duke Normandin <dukeofp...@ml1.net> wrote in news:lFaSj.3318$PM5.2947
>> > @edtnps92:

>>
>> >> Thanks for the great explanation! What is _your opinion_ of
>> >> "naked references" -- if you dare to go there.

>>
>> You've _got_ to be sh....ing me!!
>> --
>> Duke Normandin

>
> He is....a little.
>
> Here's a quick explainer:
>
> SET ^Cars("pickup",1)="Tundra" --- * Full global reference *
> SET ^(2)="Rabbit" --- * Naked global reference *


So this implies that there pre-exists something like:
SET ^Cars("compact",2)="Rabbit" ??

> SET ^(3)="ChevyS10" --- * Assume subscript level 2 *


as well as:

SET ^Cars("pickup",3)="ChevyS10" ??

> SET ^(3,1)="ChevyS104liter" --- * Go to subscript level 3 *
> SET ^(2)="ChevyS106liter" --- * Assume subscript level 3 *
>
> So a naked global reference is one where the fully qualified global
> name "^Cars("pickup"," is implied and can be called with just the
> caret and the subscript number. You can see how naked global
> references are unnessecarily confusing because they don't "spell it
> out" for the person reading the code. You've got to pick back through
> in order to see what you're referencing and it drives me nuts.


Now I see how easily "naked References" could quickly produce spaghetti
code. But why use them at all? Is there a _speed_ advantage? Something
else?
--
Duke Normandin
Reply With Quote
  #17  
Old 05-02-2008, 09:20 AM
Aaron Seidman
Guest
 
Default Re: The `if' command

Duke Normandin wrote:

> Now I see how easily "naked References" could quickly produce spaghetti
> code. But why use them at all? Is there a _speed_ advantage? Something
> else?


MUMPS was first developed in the 1960s when storage space was extremely
tight and naked references reduced the amount of storage space needed. There
are a number of such "features" in M, some of which are fine and some of
which (especially naked references) ought to be avoided. One should be very
careful in designing the database itself so that one does not store things
unnecessarily, especially if on anticipates that it will become very large.
Source code, on the other hand, is usually a small fraction of the total
amount of data on disk. Today, storage is cheap and programmer time is the
expensive commodity, so one should focus on making code clear rather than
"clever."
Reply With Quote
  #18  
Old 05-02-2008, 10:28 AM
Pete
Guest
 
Default Re: The `if' command

On May 2, 4:59 am, Duke Normandin <dukeofp...@ml1.net> wrote:
> On 2008-05-02, Pete <peter.charbonn...@gmail.com> wrote:
>
>
>
> > On May 1, 5:05 pm, Duke Normandin <dukeofp...@ml1.net> wrote:
> >> On 2008-05-01, Rilian <no...@nohow.com> wrote:

>
> >> > Naked references are bad - nude variables are encouraged.

>
> >> > Figure that one out. 8^)

>
> >> > Duke Normandin <dukeofp...@ml1.net> wrote in news:lFaSj.3318$PM5.2947
> >> > @edtnps92:

>
> >> >> Thanks for the great explanation! What is _your opinion_ of
> >> >> "naked references" -- if you dare to go there.

>
> >> You've _got_ to be sh....ing me!!
> >> --
> >> Duke Normandin

>
> > He is....a little.

>
> > Here's a quick explainer:

>
> > SET ^Cars("pickup",1)="Tundra" --- * Full global reference *
> > SET ^(2)="Rabbit" --- * Naked global reference *

>
> So this implies that there pre-exists something like:
> SET ^Cars("compact",2)="Rabbit" ??
>
> > SET ^(3)="ChevyS10" --- * Assume subscript level 2 *

>
> as well as:
>
> SET ^Cars("pickup",3)="ChevyS10" ??
>
> > SET ^(3,1)="ChevyS104liter" --- * Go to subscript level 3 *
> > SET ^(2)="ChevyS106liter" --- * Assume subscript level 3 *

>
> > So a naked global reference is one where the fully qualified global
> > name "^Cars("pickup"," is implied and can be called with just the
> > caret and the subscript number. You can see how naked global
> > references are unnessecarily confusing because they don't "spell it
> > out" for the person reading the code. You've got to pick back through
> > in order to see what you're referencing and it drives me nuts.

>
> Now I see how easily "naked References" could quickly produce spaghetti
> code. But why use them at all? Is there a _speed_ advantage? Something
> else?
> --
> Duke Normandin


The Rabbit was technically a pickup, described in my global example on
the same level as the S10 and the Tundra, with just a name. In this
example the logical extension would put:

SET ^Cars("pickup",2,1)="RabbitLX"

Where the LX was the version with the slightly larger engine. I
think. I probably should have used a modern car reference.
Reply With Quote
  #19  
Old 05-02-2008, 01:41 PM
Rod Dorman
Guest
 
Default Re: The `if' command

In article <9mDSj.76$Vd7.68@edtnps92>,
Duke Normandin <dukeofperl@ml1.net> wrote:
> ...
>Now I see how easily "naked References" could quickly produce spaghetti
>code. But why use them at all? Is there a _speed_ advantage? Something
>else?


Used properly I find theres a readability advantage and reduced chance
of a typo. e.g.
SET VehicleID=^CustomerCars(Country,State,City,Street, OtherSubscript,"VIN")
SET MilesPerGallon=^("MPG")
SET SomethingElse=^("Whatever")
-or-
SET ^("Count")=^Something(Here,There,Anywhere,"Count") +1

The danger in using naked references comes from assuming that the
naked indicator wont change when making subroutine or function
calls. It might work fine when you write and test it but break at some
point in the future if/when the subroutine is changed.

--
-- Rod --
rodd(at)polylogics(dot)com
Reply With Quote
  #20  
Old 05-02-2008, 08:25 PM
Duke Normandin
Guest
 
Default Re: The `if' command

On 2008-05-02, Aaron Seidman <aaron@imaginative-illustration.com> wrote:
> Duke Normandin wrote:
>
>> Now I see how easily "naked References" could quickly produce spaghetti
>> code. But why use them at all? Is there a _speed_ advantage? Something
>> else?

>
> MUMPS was first developed in the 1960s when storage space was extremely
> tight and naked references reduced the amount of storage space needed. There
> are a number of such "features" in M, some of which are fine and some of
> which (especially naked references) ought to be avoided. One should be very
> careful in designing the database itself so that one does not store things
> unnecessarily, especially if on anticipates that it will become very large.
> Source code, on the other hand, is usually a small fraction of the total
> amount of data on disk. Today, storage is cheap and programmer time is the
> expensive commodity, so one should focus on making code clear rather than
> "clever."


I hear you! I started programming with the Perl languageabout 10 years
ago. It can has some cryptic and rather puzzling syntax, which oftentimes
harbor some narsty bugs. ;^)
--
Duke Normandin
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:32 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.