Syntax

(Sidenote: This is an ongoing page showing sample syntax. Eventually, each section will be linked to articles explaining the choices for that syntax. If there is no link, then it's still more in the playground mode.)

'Arbitrary-ish' rules for efficiency: (These may change later)
- Minimize need of shift-symbols
- Just use the single square bracket to define scopes, instead of also the brace and parentheses.
- Everything 'replaceable'/'changeable'


Each section shows how a particular use-case could be handled. Keep in mind real code is being used and if anything looks like a placeholder, then it is likely part of the language.

The ultimate goal is to not have to mention any language for the syntax. There should be a vocabulary used that is platform-agnostic:

- app
- app.title
- app.description (do short and long?)
- app.website
- app.page
- layout.row
- layout.column
- layout.grid (this could also take the place of row and column..)
- layout.cell
- ui.button (maybe just `Clickable` interface)
- ui.input (could be text, image, file, etc)
- ui.text
- ui.image
- ui.video
- ui.audio (change all 'ui' to 'media'? or 'ux'? UX is just about everything though..)
- app.command
- app.command.hotkey ('hotkey' is more correct than 'shortcut')
- app.plugin (could be an artificial limitation, so 'extension' would be less correct? what about 'addon'? nah, not oft-used.) (this is recursive alias for 'app')

HTML/CSS/JavaScript

Anon.Website [ // Provide namespaces
  title = 'My Awesome Website Title'
  lang = 'en'
  meta [
    author = 'My Name'
    description = 'Description about my website'
  ]
  style = random style1 style2
  style1 : Anon.Website.Style [ // Provide parent/type to reuse code
    layout.title.font = 'Helvetica'
    background = red
  ]
  style2 : Style [ // Don't need redundant namespacing
    layout.title.font = random 'Times New Roman' 'Arial'
    background = random green aqua blue
  ]
  layout = random layout1 layout2
  layout [ // Another way to reduce written code for namespaces
    layout1 [
      col [
        title
        icon
        description
      ]
    ]
    layout2 [
      row [
        title
        icon
        description
      ]
    ]
  ]
]



Traditional Client and Server Code (C-based, Java, PHP, Python, Ruby)


// By default, I was thinking that all top-level closures would automatically be class. But, do we need to distinguish for other types of code uses like HTML above? Probably not, likely optional.
// Better way to do constructor with default values?
MyClass(int key = -1, String value) [
  readable key, value
  readable isSet := key != -1
]

myClass = MyClass(42, 'life') // Make parenthesis and comma optional?
myClass.key // Returns 42
myClass.isSet // Returns true


SQL

// TODO: Possibly put lambas here


Scripts (Bash,  // TODO: Put more script languages here)




Config (YAML, // TODO: put more config languages here.)

MyConfig [
  title = 'Lalala'
  name = 'Me'
  website = 'http://me.com/'
]




No comments:

Post a Comment