Augmenting smalltalksyntax

63
agile software development & services Augmenting Smalltalk with your own Control Flow Syntax www.10pines.com Hernán Wilkinson Twitter: @HernanWilkinson Blog: objectmodels.blogspot.com www.10pines.com

Transcript of Augmenting smalltalksyntax

Page 1: Augmenting smalltalksyntax

agile software development & services

Augmenting Smalltalk with your own Control

Flow Syntax

www.10pines.com

Hernán WilkinsonTwitter: @HernanWilkinson

Blog: objectmodels.blogspot.comwww.10pines.com

Page 2: Augmenting smalltalksyntax

In linguistics, syntax is the set of rules, principles, and processes that govern the structure of sentences in a given language, specifically word order. The term syntax is also used to refer to the study of such principles and processes. The goal of many syntacticians is to discover the syntactic rules common to all languages.

In mathematics, syntax refers to the rules governing the behavior of mathematical systems, such as formal languages used in logic. (See logical syntax.)

Syntax

Page 3: Augmenting smalltalksyntax

In linguistics, grammar is the set of structural rules governing the composition of clauses, phrases, and words in any given natural language. The term refers also to the study of such rules, and this field includes morphology, syntax, and phonology, often complemented by phonetics, semantics, and pragmatics.

Grammar

Page 4: Augmenting smalltalksyntax

How easy is to change the syntax?How easy is to change the grammar?

Change

Page 5: Augmenting smalltalksyntax

Complexity = essential + accidental

Complexity

Page 6: Augmenting smalltalksyntax

Complexity = essential + accidental

Complexity

We can not reduce this one

Page 7: Augmenting smalltalksyntax

Complexity = essential + accidental

Complexity

We can not reduce this one

We can definitely reduce this one

Page 8: Augmenting smalltalksyntax

Smalltalk Complexity

Page 9: Augmenting smalltalksyntax

One day, in a typical PARC hallway bullsession, Ted Kaehler, Dan Ingalls, and I were standing around talking about programming languages. The subject of power came up and the two of them wondered how large a language one would have to make to get great power. With as much panache as I could muster, I asserted that you could define the "most powerful language in the world" in "a page of code." They said, "Put up or shut up."

Page 10: Augmenting smalltalksyntax
Page 11: Augmenting smalltalksyntax

“The biggest hit for me while at SAIL in late '69 was to really understand LISP. Of course, every student knew about car, cdr, and cons, but … no one had penetrated the mysteries of eval and apply. I could hardly believe how beautiful and wonderful the idea of LISP was [McCarthy 1960]”

Page 12: Augmenting smalltalksyntax
Page 13: Augmenting smalltalksyntax

“… there were deep flaws in its logical foundations. By this, I mean that the pure language was supposed to be based on functions, but its most important components--such as lambda expressions, quotes, and conds--were not functions at all, and instead were called special forms”

Page 14: Augmenting smalltalksyntax

Closure

Page 15: Augmenting smalltalksyntax

Closure

Lisp Lambda Functions Algol-60 Block & Lexicographic binding

Scheme Closure

Page 16: Augmenting smalltalksyntax
Page 17: Augmenting smalltalksyntax
Page 18: Augmenting smalltalksyntax
Page 19: Augmenting smalltalksyntax
Page 20: Augmenting smalltalksyntax
Page 21: Augmenting smalltalksyntax

“with full closures you can avoid control flow syntax”

Page 22: Augmenting smalltalksyntax

Smalltalk Syntax

object message(and other minor stuff)

Page 23: Augmenting smalltalksyntax

if

Page 24: Augmenting smalltalksyntax
Page 25: Augmenting smalltalksyntax

Closure

Page 26: Augmenting smalltalksyntax

Does not compile!

Page 27: Augmenting smalltalksyntax
Page 28: Augmenting smalltalksyntax
Page 29: Augmenting smalltalksyntax

Example

Page 30: Augmenting smalltalksyntax

(Ruby)

Page 31: Augmenting smalltalksyntax

(Ruby)

Page 32: Augmenting smalltalksyntax
Page 33: Augmenting smalltalksyntax

while

Page 34: Augmenting smalltalksyntax

Does not compile!

Page 35: Augmenting smalltalksyntax
Page 36: Augmenting smalltalksyntax

Closure

Page 37: Augmenting smalltalksyntax

Closure

Boolean or Closure?

Page 38: Augmenting smalltalksyntax
Page 39: Augmenting smalltalksyntax

Example

Page 40: Augmenting smalltalksyntax
Page 41: Augmenting smalltalksyntax

exceptions

Page 42: Augmenting smalltalksyntax
Page 43: Augmenting smalltalksyntax
Page 44: Augmenting smalltalksyntax

Closure

Closure

Page 45: Augmenting smalltalksyntax
Page 46: Augmenting smalltalksyntax

Implicit condition… why?Implicit condition… why?

Page 47: Augmenting smalltalksyntax
Page 48: Augmenting smalltalksyntax

In how many places is ZeroDevide handled?In how many places is SubscriptOutOfBounds handled?

Page 49: Augmenting smalltalksyntax
Page 50: Augmenting smalltalksyntax

Resources

Page 51: Augmenting smalltalksyntax
Page 52: Augmenting smalltalksyntax

file will not close if an exception signals before

Page 53: Augmenting smalltalksyntax
Page 54: Augmenting smalltalksyntax
Page 55: Augmenting smalltalksyntax
Page 56: Augmenting smalltalksyntax

Syntatically solved again

Page 57: Augmenting smalltalksyntax

DSL

Page 58: Augmenting smalltalksyntax
Page 59: Augmenting smalltalksyntax
Page 60: Augmenting smalltalksyntax
Page 61: Augmenting smalltalksyntax

Conclusions

▶ Less syntax more flexibility▶ Less syntax more grammar▶ More grammar easier to change,

to augment!▶ Less syntax makes the language

yours!▶ Don’t be afraid! Make your own

language!

Page 62: Augmenting smalltalksyntax

Questions?

@[email protected]

Page 63: Augmenting smalltalksyntax

agile software development & services

[email protected]

twitter: @10Pines

ArgentinaTel.: +54 (11) 6091-3125Alem 896, 6(1001) Buenos Aires