Euphoria Programming Language CSC 507 Kasilingam Vimalan.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

PHP I.
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
RAPTOR Syntax and Semantics By Lt Col Schorsch
Programming Languages and Paradigms The C Programming Language.
Kernighan/Ritchie: Kelley/Pohl:
COEN Expressions and Assignment
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Chapter 10.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
1 Introducing ASML Methods, Values, Constraints, Constants, Variables Lecture 10 Software Engineering COMP201.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Practical Extraction & Report Language Picture taken from
Elementary Data Types Scalar Data Types Numerical Data Types Other
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
CS100A, Fall 1997, Lectures 221 CS100A, Fall 1997 Lecture 22, Tuesday 18 November Introduction To C Goal: Acquire a reading knowledge of basic C. Concepts:
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Guide To UNIX Using Linux Third Edition
JavaScript, Third Edition
VB .NET Programming Fundamentals
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations System-oriented Programming, B. Hirsbrunner,
String Escape Sequences
INTERNET APPLICATION DEVELOPMENT For More visit:
Expressions creating information. topics  operators: precedence, associativity, parentheses, overloading  operands: side-effects, coercion  arithmetic,
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Names Variables Type Checking Strong Typing Type Compatibility 1.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 6 l Array Basics l Arrays and Methods l Programming with Arrays.
I Power Int 2 Computing Software Development High Level Language Constructs.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Arrays.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Smalltalk (and Squeak) Aida Dungan and Rick Shreve.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
Looping and Counting Lecture 3 Hartmut Kaiser
4.4 JavaScript (JS) Deitel Ch. 7, 8, 9, JavaScript & Java: Similarities JS (JavaScript) is case-sensitive Operators –arithmetic: unary +, unary.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
I Power Higher Computing Software Development High Level Language Constructs.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
RUBY by Ryan Chase.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter Array Basics.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
 Array ◦ Single & Multi-dimensional  Java Operators ◦ Assignment ◦ Arithmetic ◦ Relational ◦ Logical ◦ Bitwise & other.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Camel –perldoc perlop Many operators have numeric and string version –remember Perl will.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Windows Programming Lecture 06. Data Types Classification Data types are classified in two categories that is, – those data types which stores decimal.
Object Oriented Programming Lecture 2: BallWorld.
Definition of the Programming Language CPRL
The Machine Model Memory
PHP.
C Programming Getting started Variables Basic C operators Conditionals
ENERGY 211 / CME 211 Lecture 5 October 1, 2008.
Presentation transcript:

Euphoria Programming Language CSC 507 Kasilingam Vimalan

Euphoria End-User Programming with Hierarchical Objects for Robust Interpreted Applications Created by Robert Craig from Rapid Deployment Software Created by Robert Craig from Rapid Deployment Software First released in 1993 for 32-bit DOS platform. First released in 1993 for 32-bit DOS platform. Interpreter is available for Windows, DOS, Linux and FreeBSD can be downloaded freely form Interpreter is available for Windows, DOS, Linux and FreeBSD can be downloaded freely form Can develop various applications such as Windows GUI programs, and Linux X Windows programs, CGI programs etc Can develop various applications such as Windows GUI programs, and Linux X Windows programs, CGI programs etc

Key Features of Euphoria Very simple language Very simple language Interpreted language Interpreted language Automatic memory management and garbage collection. Automatic memory management and garbage collection. Runtime type checking ( it can be turned off at runtime). Runtime type checking ( it can be turned off at runtime).

Two main Data Types 1. Atom is a number that can be either 31-bit integer or 64-bit floating-point. Example: atom a, b, c, d, e a = 'B' -- equivalent to the atom 66 b = 0 c = 1000 d = 98.6 e = -1e6

2. sequence it a collection of numeric value or atoms it a collection of numeric value or atoms can have zero or more elements can have zero or more elements each element is either an atom or a sequence each element is either an atom or a sequence it can grow dynamically at runtime it can grow dynamically at runtime The first element in a sequence has an index of one [1] The first element in a sequence has an index of one [1] Example : sequence a, b, c, d, e, f sequence a, b, c, d, e, f a = {2, 3, 5, 7, 11, 13, 17, 19} a = {2, 3, 5, 7, 11, 13, 17, 19} b = "abcd" –- this is actually {97, 98, 99,100} c = {1, 2, {3, 3, 3}, 4, {5, {6}}} d = {{"jon", "smith"}, 52389, 97.25} e = {} -- the 0-element sequence f = {x+6, 9, y*w+2, sin(0.5)}

Euphoria has two additional specialized data types: 1. Integer is a special form of atom, restricted to 31-bit integer values in the range to Object is a generic data type that can contain any of the above, and can be changed during run-time

Operators Arithmetic Operators : Arithmetic Operators : unary-, unary+, *, /, +, - Relational Operators: Relational Operators: = = != = = != Note: for string use equal() or compare() Logical Operators : Logical Operators : and, or, xor, not Other operator : Other operator : & - concatenation operator Precedence: function/type calls unary- unary+ not / + - & = = != = = != and or xor {,,, }

Expressions In Euphoria one can perform an operation on entire sequences of data with one expression. Examples: x = {1,2,3} x is {6, 7, 8} x = -{1, 2, 3, {4, 5}} --x is {-1, -2, -3, {-4, -5}} x = {5, 6, 7, 8} + {10, 10, 20, 100} -- x is {15, 16, 27, 108} w = {{1, 2}, {3, 4}, {5}} * {4, 5, 6} -- w is {{4, 8}, {15, 20}, {30}}

Logical Expression Example: 5 and (true) not (false) Short-circuit evaluation of and and or takes place for if, elsif and while conditions only. It is not used in other contexts. Examples with logical and relational operators : x = 1 or {1,2,3,4,5} x = 1 or {1,2,3,4,5} -- x is {1,1,1,1,1} w = {1, 0, 0, 1} and {1, 1, 1, 0} -- w is {1, 0, 0, 0} w = not {1, 5, -2, 0, 0} -- w is {0, 0, 0, 1, 1} w = {1, 2, 3} = {1, 2, 4} -- w is {1, 1, 0}

Subscripting/Slicing of Sequences x = {5, 7.2, 9, 0.5, 13} x[2] = {11,22,33} Then x becomes: {5, {11,22,33}, 9, 0.5, 13} y = { {{1,1}, {3,3}, {5,5}}, {{0,0}, {0,1}, {9,1}}, {{-1,9},{1,1}, {2,2}} } y[2][3][1] is 9 Array of strings: s = {"Hello", "World", "Euphoria", "", "Last One"} s = {"Hello", "World", "Euphoria", "", "Last One"} s[3] is "Euphoria" s[3][1] is 'E' Slicing of Sequences x = {1, 1, 2, 2, 2, 1, 1, 1} x = {1, 1, 2, 2, 2, 1, 1, 1} y = x[3..5] -- y is {2,2,2} y = x[3..5] -- y is {2,2,2} x[3..5] = {9, 9, 9} -- x is {1, 1, 9, 9, 9, 1, 1, 1} x[3..5] = {9, 9, 9} -- x is {1, 1, 9, 9, 9, 1, 1, 1}

user-defined types type hour(integer x) return x >= 0 and x = 0 and x <= 23 end type hour h1, h2 h1 = ok h2 = error! program aborts with a message

If statement 1.if then <statement> end if 2. if then <statement>else<statement> end if 3. if then <statement> elsif then <statement>.. end if Example: if a < b then x = 1 end if if a = 9 then x = 4 y = 5 else z = 8 end if if char = 'a' then x = 1 elsif char = 'b' then x = 2 elsif char = 'c' then x = 3 else x = -1 end if

for statement for = to [by ] do <statement> end for Example: for i = 1 to 10 do ? i -- ? is a short form for print end for for i = 10.0 to 20.5 by 0.3 do for j = 20 to 10 by -2 do ? {i, j} end for

while statement while do <statement> end while Example: i = 1 a = “hello” while i <= length(a) do ? a[i] i = i + 1 end while

Subprograms or routines There are two types of routines: Procedure and Function. Parameters: All arguments to routines are always passed by value. All arguments to routines are always passed by value. There is no pass-by-reference facility. There is no pass-by-reference facility. Sequences use copy-on-write semantics. Sequences use copy-on-write semantics.

Procedure procedure ([ ]) procedure ([ ]) end procedure Example: procedure plot(integer x, integer y) position(x, y) puts(1, '*') end procedure Note: Dose not allows to declare local variable

Functions Function is very similar to procedure, but it returns a value, and can be used in an expression. function ([ ]) function ([ ])<statement> return return end function end function function max(atom a, atom b) if a >= b then return a else return b end if end function

function swap(sequence list, integer x, integer y) object tmp tmp = list[x] list[x] = list[y] list[y] = tmp return list end function procedure permute(sequence list, integer start) if start < length (list) then for i = start to length(list) do permute(swap(list, start, i), start + 1) end for else ? list end if end procedure permute({1,2,3},1) Out put: {1,2,3}{1,3,2}{2,1,3}{2,3,1}{3,2,1}{3,1,2}

Short comes No object oriented programming support. No object oriented programming support. No exception handling. No exception handling. No concurrency support. No concurrency support.

Bibliography 1. Euphoria programming language document Wikipedia, the free encyclopedia