A Hypertalk puzzle - The Winkler test

Want to talk about something that isn't covered by another category?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 365
Joined: Mon Jun 10, 2013 1:32 pm

A Hypertalk puzzle - The Winkler test

Post by Lagi Pittas » Thu Jun 01, 2017 1:02 pm

The following was used by Rebecca Bettencourt to test the parsing of her openxion non gui version of hypertalk. She called it the Winkler Test

Craig I know you like to ponder puzzles like "does LC do it the same way as HC did?" so this ones for you.

OpenXion passed the test but try as I might I cannot get livecode to swallow this whole without major changes especially the last bit of the repeat.
I'm assuming that the missing quote at the end of the PUT line is not an error and Hypercard even parsed that "correctly".
It is basically counting from 1 to 2 and I can get the separate parts to compile by renaming the keyword variables ie aword, achar and aitem but they will not compile within the repeat loop, is this a regressive bug that Mark should be made a ware of :lol: :wink:

Code: Select all

put empty into a
put "a b c" into item
put 1 into char
put 2 into word
if true then repeat with word char of item = char char to word of word char of char to word char to char of char char of word
        put a&&"HyperTalk is a bitch to parse
end repeat else beep
the correct output is
1 "HyperTalk is a bitch to parse
2 "HyperTalk is a bitch to parse

I don't know whether Dan Winkler coded Hypertalk) or whether it was Bill Atkinson coded both the Hypercard and the language created by Winkler but it certainly shows progtramming prowess in the extreme to do all this in 68000 Assembly code.

Even more Kudos to Tom Pittman createing a full compiler that spit out 68000 machine code all in in Hypertalk itself.

Oh and Rebecca passing this test using Java - How about here on the Team she did her dissertation on a Hypercard like language
I'm Not Worthy!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: A Hypertalk puzzle - The Winkler test

Post by FourthWorld » Thu Jun 01, 2017 4:03 pm

Lagi Pittas wrote:The following was used by Rebecca Bettencourt to test the parsing of her openxion non gui version of hypertalk. She called it the Winkler Test
...

Code: Select all

put empty into a
put "a b c" into item
put 1 into char
put 2 into word
if true then repeat with word char of item = char char to word of word char of char to word char to char of char char of word
        put a&&"HyperTalk is a bitch to parse
end repeat else beep
the correct output is
1 "HyperTalk is a bitch to parse
2 "HyperTalk is a bitch to parse
Offhand I can see at least two issues there:

- Line 2: "item" is a chunk type, and as such should not be used as a variable name.
"Item" is semantically akin to an adjective, but used here as a noun. The expression "into item 1 of tString" would make sense, but simply "into item" makes no more sense than telling your doctor you have a pain in your "left", without specifying whether you mean "left arm", "left leg", "left kidney", etc. A doctor would be correct to express confusion with that, as would any script parser being confused with that line as written.

- Second-to-last line: No closing quote for the string.
I don't know of any language where not specifying the end of a string literal would be acceptable. In HTML, the absence of a closing element causes everything following the opening element to be assigned that element's attributes. Most (including JavaScript) will simply throw an error. Here it seems there's an expectation that CR should be handled as a synonym for double-quotes. Such an expectation seems murky.

If HyperCard flagged neither as an error, that itself would seem an error.
I don't know whether Dan Winkler coded Hypertalk) or whether it was Bill Atkinson coded both the Hypercard and the language created by Winkler but it certainly shows progtramming prowess in the extreme to do all this in 68000 Assembly code.
The idea of adding a scripting language to Wildcard (HC's code name), which was originally conceived as having point-and-click authoring only, is a controversial topic, with a couple different versions floating around as to how that happened. But I believe once the decision was made it was mostly the work of Dan Winkler to flesh out the details.
Even more Kudos to Tom Pittman createing a full compiler that spit out 68000 machine code all in in Hypertalk itself.
Did you use it? It was very inventive indeed, but required using syntax that was often very different from scripts compatible with the HyperTalk interpreter, understandable given the very different requirements and goals.

And that's how it's been with just about everything that was HyperCard-like but not HyperCard itself. OMO, SuperCard, Toolbook, Gain Momentum, Plus, and maybe a couple others - they each brought something different to the table, and had different syntax to support their different goals.

Explorations comparing HyperCard and later dialects can sometimes be interesting, but so much of the world of scripting, and even computing in general, has changed so much that we can expect the many differences in implementations to only continue to grow over time.

Spanish is based on Latin, but a modern Spanish speaker can't be expected to understand everything said in Latin.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: A Hypertalk puzzle - The Winkler test

Post by dunbarx » Thu Jun 01, 2017 6:12 pm

Hi.

HC seems to compile this monstrosity without complaint. And it works fine, since "true" in the handler is never. er, "false". Richard's comments about using reserved words is telling, but HC was always looser in that regard than LC.

HC was originally written mainly in Pascal, because that is what Bill Atkinson "spoke", in his words. It was rewritten a few years later in some "C" variant, to be more modern and manageable.

Dan Winkler was indeed the driving force behind Hypertalk. Atkinson had a more "user level 4" view of things. Both were astonished at the response and the demand for detailed information about every aspect of "level 5" functionality.

What LC needs is a Danny Goodman; a single reference work that covers it all. Such an undertaking would be enormous, of course. LC is far richer and larger than HC.

Craig

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 365
Joined: Mon Jun 10, 2013 1:32 pm

Re: A Hypertalk puzzle - The Winkler test

Post by Lagi Pittas » Thu Jun 01, 2017 10:38 pm

Hi Richard

Code: Select all

- Line 2: "item" is a chunk type, and as such should not be used as a variable name.
"Item" is semantically akin to an adjective, but used here as a noun. The expression "into item 1 of tString" would make sense, but simply "into item" makes no more sense than telling your doctor you have a pain in your "left", without specifying whether you mean "left arm", "left leg", "left kidney", etc. A doctor would be correct to express confusion with that, as would any script parser being confused with that line as written.
I do know why it doesn't work in LC (and rightly so) - mainly for the same reason it wouldn't work in Compileit - Hypercard was an interpreter (with a JIT compiler added later) but the fact that HC could make sense of that with all the language keywords in there (whether with or without a missing quote) still is a feat of superhuman parsing code by Dan Winkler (thanks Craig) and - no Bison or Lex to be seen.

And as Craig has just pointed out the missing quote wasn't an error

Thanks also, Craig for reminding me that Bill wrote his application programs in Pascal (my favourite language - before livecode lol) I was thinking of the Quickdraw library.


Regards lagi

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: A Hypertalk puzzle - The Winkler test

Post by FourthWorld » Fri Jun 02, 2017 2:29 am

Lagi Pittas wrote:And as Craig has just pointed out the missing quote wasn't an error
Try it. LC flags the first error, and when you correct that it flags the next one, and so on. There are several there, and when you fix enough of them to get to the string without the closing quote LC will then flag that one too.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 365
Joined: Mon Jun 10, 2013 1:32 pm

Re: A Hypertalk puzzle - The Winkler test

Post by Lagi Pittas » Fri Jun 02, 2017 9:55 am

Hi Richard

I did spend an inordinate amount of time trying to get it to compile without removing any of the keywords.

I added the quote first as I knew LC would fail. I added an "x" in front of the variables and the variables in the repeat line. The repeat would not compile.
The last part after the main "to" within brackets wouldn't compile if left in the repeat line, but it would in a line by itself with "put" - outputting the number "2".

So the parsing of expressions within a repeat is a little bit different outside of a repeat..

Anyway an interesting excursion into the past. -- reminds me a bit of html where the browser writers wrote the parsing to "fix" or at least display or skip over illegal syntax and each one did it a bit differently.

Lagi

Tony
Posts: 9
Joined: Sat Dec 15, 2012 8:52 pm
Location: Iowa City

Re: A Hypertalk puzzle - The Winkler test

Post by Tony » Fri Jun 02, 2017 6:15 pm

dunbarx wrote:
What LC needs is a Danny Goodman; a single reference work that covers it all.
Every time I launch LiveCode, I have this same thought.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: A Hypertalk puzzle - The Winkler test

Post by FourthWorld » Fri Jun 02, 2017 7:31 pm

Tony wrote:
dunbarx wrote: What LC needs is a Danny Goodman; a single reference work that covers it all.
Every time I launch LiveCode, I have this same thought.
They HyperCard manual was good, but sparse. Goodman's book really went the distance to show more of the depth of the language.

We have several good books in our community so far, with new learning materials coming online all the time - check out Andre Garzia's upcoming course:
https://docs.google.com/forms/d/e/1FAIp ... rm?c=0&w=1

But even in the install, the learning materials are pretty good. LiveCode's 653-page User Guide covers a lot of ground, and the 78 tutorials included provide a wide range of exercises to explore LC concepts in context.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Off-Topic”