[comp.sys.mac.hypercard] "Initialize" for HyperTalk

jgsmith@watson.bcm.tmc.edu (James G. Smith) (11/22/89)

Dear Apple,

   One thing I would like for Christmas is an "Initialize" command for 
HyperTalk.  I'm tired of scripting:

put empty into temp1
put empty into temp2
put empty into temp3

when I could just say

initialize temp1,temp2,temp3

How 'bout it?

*
(just a thought)

SAS102@PSUVM.BITNET (Steven A. Schrader) (11/22/89)

In article <1827@gazette.bcm.tmc.edu>, jgsmith@watson.bcm.tmc.edu (James G.
Smith) says:
>
>Dear Apple,
>
>   One thing I would like for Christmas is an "Initialize" command for
>HyperTalk.  I'm tired of scripting:
>
>put empty into temp1
>put empty into temp2
>put empty into temp3
>
>when I could just say
>
>initialize temp1,temp2,temp3
>
>How 'bout it?

Hear! hear!  I also hate that .. Mebbe I should just right my own script
but this is a real pain.  I would also like to see supported  a paramter
list like so
Procedure param1, param2, param3, param4

I hate having to throw everything down and then use statements like

Procedure ParamList
Put item 1 of ParamList into Param1
put item 2 of ParamList into Param 2
-------
                    Steven A. Schrader
              (SAS102@Psuvm       SAS@Psuarch)
_________________________________________________________________________
                    227C Computer Building
                    The Pennsylvania State University
                    University Park, Pa. 16802
                    Phone : (814) 865 - 2160

                     343 Strouse Ave.
                     State College, Pa. 16803
                     (814)  237 - 8196

ianf@nada.kth.se (Ian Feldman) (11/22/89)

jgsmith@watson.bcm.tmc.edu (James G. Smith) writes:
>
>Dear Apple,
>
>   One thing I would like for Christmas is an "Initialize" command for 
>HyperTalk.  I'm tired of scripting:
>
>put empty into temp1
>put empty into temp2
>put empty into temp3
>
>when I could just say
>
>initialize temp1,temp2,temp3


  I have to disagree with that, strongly.  The present requirement of
  conceptually putting "empty" into a container is, how strange it
  may sound, at least consistent with the rest of the HyperTalk syntax.
  Replacing that with an express "initialization" of same would introduce
  a concept that is quite foreign to the way people start up processes,
  in coding as well as in life.  We do not, after all, initialize a car
  before going on a journey, nor do we initialize a book prior to reading
  it.  HyperCard is supposed to be a common man's software erector kit.
  No need therefore to complicate matters further.  There is enough
  complexity in the HyperTalk as it is.

  You might consider the following construct as the solution to your
  personal wish:

  Create a hidden, background, field that holds the names of all
  your variables to be initialized, delimited by commas ("items").

  Put the following two handlers in the Scrapbook for import into each
  and every one of your stacks' scripts (select stack- or first-card's
  background scripts).  The code will work in any stack as long as there
  is a field in the hierarchy, corresponding to the given name. 

  on action     -- pick a condition that's true only once per run
     initialize -- name of handler in same, or higher placed, script
  end action

  on initialize
     repeat with i= 1 to the number of items in fld "variables_to_init"
       put empty into (item i of fld "variables_to_init")
     end repeat   
  end initialize

--Ian Feldman /  ianf@nada.kth.se || uunet!nada.kth.se!ianf
             / "Let's get out of this place and nuke it from orbit" -- Alien

msriram@tut.cis.ohio-state.edu (M G SriRam) (11/22/89)

Until a real initialize command shows up perhaps an idea like
the following will be useful.  This code (obviously!) initializes
the variables temp1 through temp10 to 0.


repeat with n = 1 to 10
 do "put 0  into temp"&n
end repeat

SAS102@PSUVM.BITNET (Steven A. Schrader) (11/22/89)

In article <2371@draken.nada.kth.se>, ianf@nada.kth.se (Ian Feldman) says:
>
>jgsmith@watson.bcm.tmc.edu (James G. Smith) writes:
>>
>>Dear Apple,
>>
>>   One thing I would like for Christmas is an "Initialize" command for
>>HyperTalk.  I'm tired of scripting:
>>
>>put empty into temp1
>>put empty into temp2
>>put empty into temp3
>>
>>when I could just say
>>
>>initialize temp1,temp2,temp3
>
>
>  I have to disagree with that, strongly.  The present requirement of
>  conceptually putting "empty" into a container is, how strange it
>  may sound, at least consistent with the rest of the HyperTalk syntax.
>  Replacing that with an express "initialization" of same would introduce
>  a concept that is quite foreign to the way people start up processes,
>  in coding as well as in life.  We do not, after all, initialize a car
>  before going on a journey, nor do we initialize a book prior to reading
>  it.  HyperCard is supposed to be a common man's software erector kit.
>  No need therefore to complicate matters further.  There is enough
>  complexity in the HyperTalk as it is.
>
I disagree, adding a function called Initalize () would add no more
complexity, but WOULD allow more experienced programmers a quick
initilization.  Hypertalk has a lot of functions that are available, but
adding more will not add complexity.  A good example is offset.  You
could do without it and look on your own, or if you know it is there use
it.  This would be the same as a Initilization function.  The old way
would work, but a function to make less typer also would be better ...
-------
                    Steven A. Schrader
              (SAS102@Psuvm       SAS@Psuarch)
_________________________________________________________________________
                    227C Computer Building
                    The Pennsylvania State University
                    University Park, Pa. 16802
                    Phone : (814) 865 - 2160

                     343 Strouse Ave.
                     State College, Pa. 16803
                     (814)  237 - 8196

kenk@tellab5.TELLABS.COM (Ken Konecki) (11/22/89)

| 
| Dear Apple,
| 
|    One thing I would like for Christmas is an "Initialize" command for
| HyperTalk.  I'm tired of scripting:
| 
| put empty into temp1
| put empty into temp2
| put empty into temp3
| 
| when I could just say
| 
| initialize temp1,temp2,temp3

I strongly disagree. This can be easily done through a Hypertalk
script (and was already posted) or through an XFCN. No other language
I know has this function (although some do guarantee initial values,
I've always been taught it's bad programming practice not to
explicitly initialize variables) so why should Hypertalk be any
different?

Additional food for thought: what if I didn't want to initialize my
variables to empty? So now I would have to do it by hand anyway, so
the initialize command hasn't helped me in the least.

Cheers,
    -Ken K
-- 
Ken Konecki
"Eat well, stay fit, and die anyway"
e-mail:kenk@tellabs.com    -or-    ...!uunet!tellab5!kenk	
U.S. Mail: 1271 Portchester Circle, Carol Stream, IL 60188

tim@hoptoad.uucp (Tim Maroney) (11/22/89)

In article <1827@gazette.bcm.tmc.edu> jgsmith@watson.bcm.tmc.edu
(James G. Smith) writes:
>   One thing I would like for Christmas is an "Initialize" command for 
>HyperTalk.  I'm tired of scripting:
>
>put empty into temp1
>put empty into temp2
>put empty into temp3
>
>when I could just say
>
>initialize temp1,temp2,temp3

A better syntax would be "local temp1,temp2,temp3".  This would be
parallel to the "global" command.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Please help support the moratorium on meaningless quotes in .signatures."
  -- Doug Asherman on rec.music.cd

pepke@loligo (Eric Pepke) (11/27/89)

In article <1827@gazette.bcm.tmc.edu> jgsmith@watson.bcm.tmc.edu (James G. Smith) writes:
>   One thing I would like for Christmas is an "Initialize" command for 
>HyperTalk.  I'm tired of scripting:
>
>put empty into temp1
>put empty into temp2
>put empty into temp3
>
>when I could just say
>
>initialize temp1,temp2,temp3

"Initialize" really doesn't mean much in a general sense, as you don't really
know what the best initial value for all applications is.  On the other hand,
how about something like

put empty into temp1, temp2, temp3

which would be analogous to C's

temp1 = temp2 = temp3 = NIL;

It would be very easy to add to the HyperTalk, if HyperTalk be designed
properly.  The HC help uses a notation similar to BNF, so let's assume, just
for laughs, that HyperTalk is somewhere specified using phrase structure 
rules*, and there exist rules like

<command> ::= put <source> [before | into | after] <destination>
<destination> ::= <container>

Then, you would just have to change the second rule to read

<destination> ::= <container> | <destination> , <container> 

The only problem might be that commas are used elsewhere in the syntax.
However, the parser generator** should be able to detect such ambiguities.

Eric Pepke                                     INTERNET: pepke@gw.scri.fsu.edu
Supercomputer Computations Research Institute  MFENET:   pepke@fsu
Florida State University                       SPAN:     scri::pepke
Tallahassee, FL 32306-4052                     BITNET:   pepke@fsu

Disclaimer: My employers seldom even LISTEN to my opinions.
Meta-disclaimer: Any society that needs disclaimers has too many lawyers.

Cynical footnotes:
* Ha!
** HAHA!