Paste number 21937: Example of new syntax

Index of paste annotations: 1 | 2 | 3

Paste number 21937: Example of new syntax
Pasted by: Arnia
2 years, 6 months ago
#swhack
Paste contents:
Raw Source | XML | Display As
#!/usr/bin/env pluvo

% hello.pvo - Pluvo Hello World Program

Dog = (name)
   ! hasTail?
      say "Do I have a tail?"
      return "Yes"
   ! barkUsing: bark withName: nom
      say "$nom says: "
      say "$bark! $bark! I am a dog."
   ! barkAt: obj
      say "$name barks at $obj"

main = (argv)
   rover = Dog("rover")
   rover to barkUsing: "WOOF" withName: "Sandy"
   rover to barkAt: "Tiddles"
   say {ask rover hasTail?}

script main

Annotations for this paste:

Annotation number 1: Syntax Idea
Pasted by: sbp
2 years, 6 months ago
Paste contents:
Raw Source | Display As
#!/usr/bin/env pluvo

% exclaim.pvo - Exclamation Test

Dog = (name)
   method hasTail?
      say "Do I have a tail?"
      return "Yes"

   method barkUsing: bark withName: nom
      say "$nom says: "
      say "$bark! $bark! I am a dog."

   method barkAt: obj
      say "$name barks at $obj"

main = (argv)
   rover = Dog("rover")

   # Not sure what to use for "@ask" yet
   @ask rover barkUsing: "WOOF" withName: "Rovina"
   @ask rover barkAt: "Mr. Tiddles"

   say {@ask rover hasTail?}

script main

Annotation number 2: Further Scriptgeneering
Pasted by: sbp
2 years, 6 months ago
Paste contents:
Raw Source | Display As
#!/usr/bin/env pluvo

% exclaim.pvo - Exclamation Test

Dog = (name)
   # Now, method is under consideration...
   method hasTail?
      say "Do I have a tail?"
      return "Yes"

   method barkWithName: nom saying: bark
      say "$nom says: "
      say "$bark! $bark! I am a dog."

   method barkAt: obj
      say "$name barks at $obj"

main = (argv)
   rover = Dog("Rover")
   rover, barkWithName: "Rovina" saying: "WOOF"
   rover, barkAt: "Mr. Tiddles"
   say {rover, hasTail?}

script main

Annotation number 3: Comments
Pasted by: Arnia
2 years, 6 months ago
Paste contents:
Raw Source | Display As
No, I think methods and actions should be kept separate. As I said, there is an extreme semantic difference and this should be explicit. Plus, I can forsee handling actions differently in future when we target another runtime than the python one (with its co-comintant change in backend language)


def Dog (name)
   ! barkWithName: nom saying: sound
      say "$nom says: $sound! $sound!"

def main (argv)
   rover = Dog("Rover")
   rover, barkWithName: "Rovina" saying: "WOOF"

Colorize as:
Show Line Numbers
Index of paste annotations: 1 | 2 | 3

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.