FLEXIBO Language Design - PowerPoint PPT Presentation

About This Presentation
Title:

FLEXIBO Language Design

Description:

Programming languages form an interface between computer science and ... Integration of UML. Predicative semantics and proof of development non-monotonicity. ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 22
Provided by: cyf44
Category:

less

Transcript and Presenter's Notes

Title: FLEXIBO Language Design


1
FLEXIBO Language Design
  • Work-in-Progress
  • Yifeng Chen
  • University of Leicester

7 May 2004 UNU/IIST, Macau
2
Language Design
  • Programming languages form an interface between
    computer science and computer engineering.
  • Good software engineering practice eventually
    goes into language design.

3
Design Philosophy of FLEXIBO
  • Open source with different levels of trust in
    decentralized multi-user environment.
  • Developing Testing Running
  • Limiting the effective scope of bugs.
  • Specifications with optional controls.
  • True flexibility flexibility inflexibility.
  • Compilation as execution.

4
Main Features
  • Everything is a value.
  • Classes, types, methods and specifications of
    different shapes.
  • Variables of different colors.
  • Correctness, ownership, resources control and
    smooth exception handling.
  • Run-time type checking for compilation.
  • Full Java access

5
Example Program Hello World!
  • print "Hello world!"

6
Imperative Programming
  • var x 12, "A string in an array"
  • x0 x0 1
  • if x0gt12 print "yes\n" else print "no\n"
  • var x"inside a block\n" print x
  • var x"inside another block\n" print x
  • while xgt0 print x x x - 1
  • while true

7
Class, Method and Invocation
  • var c class Value
  • var dynamic x "static value in class\n"
  • var static n method x var x"value of
    local variable\n" return x
  • var static m method x return x
  • var o new c print o.n "value from
    argument\n"
  • print o.m ! "value from argument\n"
  • print o. (1 m ! 2)

8
Specification and implementation
  • var spec specification x,y pre true post
    true
  • spec.implementbody (x "I implement by adding
    a prefix to "x return x)
  • print spec"the argument.\n",2
  • spec specification x,y pre true post true
  • print spec"the argument.\n",2

9
Ownership Control
  • print project // show the shared project
  • project.spec "I have modified changed this
    specification."
  • print project // show its change
  • project.spec "I have reset this
    specification."
  • project "I want to delete the whole project."
  • print project // This point is not reachable.

10
Exception Handling
  • try print 1true
  • catch "Cannot add" print "I have caught it.\n"
  • var timer new tclass
  • try timer.start2000 while true
  • catch "" print "I have caught my own timeout
    error.\n"
  • timernew tclass
  • try timer.start5000 while true
  • catch "" print "I cannot catch the server's
    timeout.\n"

11
Overloading Method Invocation
  • var c class Value var m method a
    return a
  • var n class Value var invoke method a
    return "Overloading method invocation is "a
  • print (new c).m "invoked in a usual way\n" //
    x-gtm-gta
  • var xnew c print ((x.m).invoke "Invoked as a
    pre-defined method\n")
  • print (new c).n "invoked in a usual way\n" //
    x-gtm-gta
  • print ((x.n).invoke "invoked as a normal
    method\n")

12
Side Effect and Evaluation Order
  • var a "Evaluated as an argument"
  • var c class Value
  • var dynamic y
  • var m method z print z
  • var env class Value var x new c
  • env . ( (print "Evaluate x in env\n" x). (print
    "Evaluate m in x\n" m) (print "Evaluate a in
    the defined environment.\n" a) )

13
Language Reflection
  • print quote (1 "A quoted exp is not
    evaluated.")
  • var c class Value
  • var v"\nA value in a class\n"
  • var b body (print v)
  • print (c.b).eval

14
Methods in Different Shapes
  • var c class Method var dynamic msg "together
    with a document of the method.\n"
  • var init method x print msg return x
  • var m new cquote (y), body (print y)
  • print m"Invoking a user-defined kind of
    method.\n"

15
Colored Variables (attvar)
  • var P class Value var type "Type of
    Persons\n"
  • var returnType method return atttype
  • var S class P var type "Type of Staff\n"
  • print (new P).returnType // or (new
    P).attreturnType
  • print (new S).returnType

16
Colored Variables (defvar)
  • var SimpleAccount class Value
  • var dynamic private deposit200
  • var dynamic private withdrawal100
  • var getTotal method return (deposit -
    withdrawal)
  • var payable method payment return (paymentlt
    defgetTotal)
  • var Account class SimpleAccount
  • var dynamic private savings 400
  • var getTotal method return
    (super.getTotal savings)
  • var sa new SimpleAccount
  • print sa.payable200 // not payable
  • var a new Account
  • print a.payable200

17
The Default Rule
  • y . ( x . m ! a )
  • y --- def variable (evaluated in defined env)
  • x --- att variable (evaluated in y)
  • m --- att variable (evaluated in x)
  • a --- def variable (evaluated in defined env)
  • The default rule implies dynamic binding.

18
Colored Variables (gen/rawvar)
  • var Account class Value
  • var dynamic deposit200
  • var dynamic withdrawal100
  • var genbalance((deposit - withdrawal),
  • method b deposit b
    withdrawal)
  • var account new Account
  • print account.balance
  • account.balance 300 // updation
  • print account.balance
  • print account.rawbalance // return the
    expressions

19
Types and Run-time Checking
  • print "This must be a string according to the
    type constraint.\n"String
  • print Int Float - Int // This is used for
    user-defined type checking algorithm.
  • print "This string is wrongly typed!" Int

20
User-defined Types
  • var YType class Value var dynamic type
  • var init method t type t return
    this
  • var check method t return type lt
    t.getType
  • var Persons class Value var msg "I am a
    person.\n"
  • var Staff class Persons var msg "I am a
    staff.\n"
  • var YStaff new YTypeStaff
  • var sYStaff // Upwards-closure type
  • s new Persons print s.msg
  • var pStaff // Normal type requires exact match.
  • p new Persons print s.msg

21
Future Work
  • Client-side HCI (using Java RMI).
  • From FlexibO to C.
  • Exploring the new mechanisms.
  • Integration of UML.
  • Predicative semantics and proof of development
    non-monotonicity.
Write a Comment
User Comments (0)
About PowerShow.com