Post Reply 
Can't reproduce HP-28 operations as objects example
04-08-2020, 10:01 PM
Post: #1
Can't reproduce HP-28 operations as objects example
The HP-28 Programming Insights book, in section 3.2.1. gives the example

1 2 {+} LIST→ DROP

to illustrate how operations are treated as objects, stating that placing the + in {..} ensures that it will be placed on the stack rather than being executed when [ENTER] is pressed, and resulting in

1
2
+


on the stack. However if I try to reproduce this I only get as far as

1 2 {+

which results in

1
{2}


on the stack.

What's going on here. Why can't I reproduce the example in the book?
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2020, 10:29 PM
Post: #2
RE: Can't reproduce HP-28 operations as objects example
During normal operation, the active entry mode is "immediate-execution", in which several keys, among which the [+] key, perform an implicit ENTER. Otherwise, you would have to press [+], followed by an explicit [ENTER], even in very trivial calculations like 1 2 +. Besides being unnecessarily convoluted, such an entry system would also break compatibility with all previous RPN calculators.

To solve your problem, just activate ALPHA mode (by pressing [α]) before pressing [+]. This will simply add the "+" to the text already present in the command line, without executing the latter.
Find all posts by this user
Quote this message in a reply
04-08-2020, 10:34 PM
Post: #3
RE: Can't reproduce HP-28 operations as objects example
(04-08-2020 10:29 PM)Giuseppe Donnini Wrote:  During normal operation, the active entry mode is "immediate-execution"...

Yes, that's the context for the example. And the example is intended to illustrate how that mode works. So is the example wrong?
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2020, 10:40 PM
Post: #4
RE: Can't reproduce HP-28 operations as objects example
(04-08-2020 10:34 PM)Orome Wrote:  
(04-08-2020 10:29 PM)Giuseppe Donnini Wrote:  During normal operation, the active entry mode is "immediate-execution"...

Yes, that's the context for the example. And the example is intended to illustrate how that mode works. So is the example wrong?
Page 23, just above the example: Try this (use alpha mode to enter the +):
Find all posts by this user
Quote this message in a reply
04-08-2020, 10:47 PM
Post: #5
RE: Can't reproduce HP-28 operations as objects example
(04-08-2020 10:40 PM)Sylvain Cote Wrote:  Page 23, just above the example: Try this (use alpha mode to enter the +):

Interesting. It doesn't say that in my version of the book (First Edition
First Printing, May 1988; the one on the Museum Document Set)!
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2020, 10:54 PM
Post: #6
RE: Can't reproduce HP-28 operations as objects example
(04-08-2020 10:47 PM)Orome Wrote:  
(04-08-2020 10:40 PM)Sylvain Cote Wrote:  Page 23, just above the example: Try this (use alpha mode to enter the +):

Interesting. It doesn't say that in my version of the book (First Edition
First Printing, May 1988; the one on the Museum Document Set)!

Guess we now know why they added that note.... Wink

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
04-08-2020, 11:05 PM
Post: #7
RE: Can't reproduce HP-28 operations as objects example
HP-28 Insights
Principles and Programming of the HP-28C/S
Copyright William C. Wickes 1988
Larked Publications
First Edition
Third Printing, December 1989
ISBN 0-9625258-1-2
Find all posts by this user
Quote this message in a reply
04-16-2020, 07:34 PM
Post: #8
RE: Can't reproduce HP-28 operations as objects example
FWIW, the HP 48 Insights book replaces this confusing example with a better one:

1 2 {+} HEAD

with no need for the distracting switch to alpha mode.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-17-2020, 09:15 PM (This post was last modified: 04-17-2020 09:17 PM by Giuseppe Donnini.)
Post: #9
RE: Can't reproduce HP-28 operations as objects example
You are confusing two things here.

It's not the example that is better, but the calculator!

Replacing LIST\-> DROP by HEAD (which is simply not available on the HP-28, nor on the HP-48SX, for that matter) has no impact whatsoever on the problem at hand. But something else has: On the '48 (both SX and GX), pressing [LS] + {} automatically activates program mode (formerly known as ALPHA mode) for you. And it also adds the closing brace.
Find all posts by this user
Quote this message in a reply
04-17-2020, 09:27 PM
Post: #10
RE: Can't reproduce HP-28 operations as objects example
(04-17-2020 09:15 PM)Giuseppe Donnini Wrote:  ... has no impact whatsoever on the problem at hand.

I'm not sure what you mean. The "problem at hand" was illustrating operations as objects. The capabilities of the 48G allows for a better illustration of that (otherwise why abandon the original illustration, which works fine on the 48G?).
Visit this user's website Find all posts by this user
Quote this message in a reply
04-17-2020, 10:12 PM (This post was last modified: 04-17-2020 10:34 PM by Giuseppe Donnini.)
Post: #11
RE: Can't reproduce HP-28 operations as objects example
(04-17-2020 09:27 PM)Orome Wrote:  the HP 48 Insights book replaces this confusing example with a better one:

1 2 {+} HEAD

with no need for the distracting switch to alpha mode.

...clearly implies that it was the replacement of LIST\-> DROP with HEAD that obviated the need for switching to ALPHA mode (this is what I referred to as "the problem at hand", since you called it "distracting").

But this is not true at all. It is due to the new feature of the '48 (both of the S and of the G models) to activate ALPHA, or PRG, mode automatically, as soon as you begin to type in a list.

Take a look at page 29 of the SX version of "Insights", and you will see that no switching is necessary, even though HEAD is not available.
Find all posts by this user
Quote this message in a reply
04-17-2020, 10:19 PM (This post was last modified: 04-17-2020 10:25 PM by Orome.)
Post: #12
RE: Can't reproduce HP-28 operations as objects example
(04-17-2020 10:12 PM)Giuseppe Donnini Wrote:  ...you called it "distracting").

I'm not sure what's confusing about this: "it" is having to remember to enter alpha mode, the omission of which was the source of the error in the first edition of the book.

EDIT: Oh I see, sorry. I don't mean that the example is better because of the lack of the need to switch to alpha mode. I just meant it's a better example as such (at least, imv) and (BTW) also (thanks to the automatic alpha in a list) doesn't need the (manual) switch to alpha.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-17-2020, 11:12 PM (This post was last modified: 04-18-2020 06:43 AM by Giuseppe Donnini.)
Post: #13
RE: Can't reproduce HP-28 operations as objects example
(04-17-2020 10:19 PM)Orome Wrote:  Oh I see, sorry. I don't mean that the example is better because of the lack of the need to switch to alpha mode.

That's exactly what I thought you meant. Thanks for the clarification.

(04-17-2020 10:19 PM)Orome Wrote:  I just meant it's a better example as such (at least, imv)

In what way exactly? Just because it is shorter? In order to illustrate the concept of "operations as objects" it is necessary to put an operation (i.e. an RPN command or a function) on the stack. While this is easily done in System RPL where you can apply the quote operator " ' " to any object you want, including procedure class objects, it is not as straightforward in User RPL. Hence the trick to first embed it in a list, which ensures that it remains in passive form, then extract it from there. However, the way in which this extraction is actually done, is rather secondary. You could also use 1 GET on all machines, from the HP-28C to the HP-48GX, which, though longer, would be less "obscure" than HEAD in my opinion.
Find all posts by this user
Quote this message in a reply
04-18-2020, 12:11 AM (This post was last modified: 04-18-2020 06:21 PM by Orome.)
Post: #14
RE: Can't reproduce HP-28 operations as objects example
(04-17-2020 11:12 PM)Giuseppe Donnini Wrote:  In what way exactly?

Just preference or background I expect, like any opinion. HEAD is what I think if when grabbing the start of a list.

How would you do the equivalent, BTW, on a Prime?
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)