Re: Spoken programming language
From: | Ina van der Vegt <gijsstrider@...> |
Date: | Saturday, January 3, 2009, 21:15 |
> The syntax "apple.color == red" seems to mean "The apple is red?" with an implied question mark.
>
> I still think the following kind of distinction needs to be made:
>
> Assert(apple.color == red); // "I assert/claim/state that the apple is red."
>
> Query(apple.color == red); // "Is the apple red?"
>
> Imperative(apple.color = red); // "Make the apple red!"
apple.color == red; //Statement, can be either true or false. Remember
that programming languages are a type of loglang, as computer science
is a type of formal logic. Of course, since statements are not very
useful if you don't check their truth, this is not actually used.
If(apple.color == red); //A query which evaluates whether this is true.
apple.color = red; //The apple's color is/has become red. The computer
then updates his data to account for this new information.
Translating the following program to english after the program.
{
fruit apple == new fruit();
apple.color = colors.red;
apple.shape = shapes.approximate.sphere;
apple.taste = tastes.sweet & tastes.sour;
if(apple.age > apple.age.old){
apple.color = brown;
apple.taste = tastes.sweet; //No longer sour.
apple.nutrition = nutrition.poor;}
}
The apple is a red coloured fruit that is approximately shaped like a
sphere. It tastes sweet and sour. If an apple's age is old, it's
colour becomes brown, it's solely sweet, and it's nutritionaal value
becomes poor.