Theiling Online    Sitemap    Conlang Mailing List HQ    Attic   

Re: Spoken programming language

From:Lars Finsen <lars.finsen@...>
Date:Sunday, January 4, 2009, 0:59
Den 3. jan. 2009 kl. 22.30 skreiv Paul Kershaw:
> > I think a major obstacle to using computer language syntax for > natural languages is the function of each sort of communication. > Computer language is used almost exclusively to give commands to a > subordinate system (i.e., the computer). If we're asking if an > apple is red, it's because we want to know so that we can give an > order concerning the apple (e.g., if (apple.color = red) pick > (apple) -> "Is the apple red? If so, pick it!"), not because we're > just curious or making idle conversation. So regardless, if we > wanted to make computer language robust enough to tell stories, I > agree, we'd need to build quite a bit of new structures.
I think you could tell just about any story in Smalltalk. Smalltalk works by declaring objects and communicating with them. It is largely programmed in itself, and any structure you lack can be defined more or less easily. Den 3. jan. 2009 kl. 22.15 skreiv Ina van der Vegt:
> { > 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.
Smalltalk version: sphere:= Shape new: #sphereEquation. apple:= Product new: #fruit colour: #red shape: sphere approximated taste: #(#sweet #sour) nutritionalValue: #good. The apple now needs a message like this: age: value value = #old ifTrue: [colour:= brown. taste: #(#sweet) nutritionalValue: #poor]. ^self If you send the message "age: #old" to the apple, it returns a modified self. If you send the "age:" message with any other value, it returns an unmodified self. Smalltalk is the mother of all object-oriented systems, and still the most fun to use. LEF