V (programming language)

V (programming language)

Infobox programming language
name = V
logo =
paradigm = multi-paradigm: functional, stack-oriented
year = 2007
designer = "Rahul"
developer = "Rahul"
latest release version = Jun 1, 2007
latest release date = Jun 1, 2007
typing = dynamic
implementations = native V and on JVM
dialects =
influenced_by = Joy, PostScript
influenced =

The V programming language is a purely functional programming language based on composition of functions rather than lambda calculus [http://www.latrobe.edu.au/philosophy/phimvt/joy/j03atm.html] . It was inspired by Joy but is closer in spirit to PostScript.

Features

Concatenative

The language is concatenative, meaning that it is based on composition of functions and does not have a need for formal parameters. It is also stack based with postfix notation. Every thing is a function (also called a word) in this language. Each word takes its arguments from the stack and places its output(s) in the stack. The literals (strings and numbers) are functions that consume nothing but place themselves in the stack.

Arithmetic

2 3 * 4 +will compute (2 * 3) + 4 2 dup *will compute 2 * 2 (dup is a word that duplicates the top most word in the stack)

Homoiconic

The primary data structure is the Quote, represented by ' [' and '] ' It is also used to represent the code.

Definitions

Unlike Joy which enforces static word definitions, V allows definition of words during runtime using the word '.' It is similar to PostScript in this respect.

Defining the word square in v

The word '.' pops the last quote from the stack, splits it into a pair containing name and definition, and associates the name with the definition. [square dup *] .

QuickSort

The Quick sort is defined as below. Notice how the input to qsort is in the same form as the definition of qsort itself.

[qsort [joinparts [pivot [*list1] [*list2] : [*list1 pivot *list2] view] . [split_on_first_element uncons [>] split&] . [small?] [] [split_on_first_element] [joinparts] binrec] .

Using Qsort: [0 9 6 7 8 4 6 2] qsort

Explanation

The first two lines (joinparts and split_on_first_element) are local word definitions. They are used later inside binrec. (The joinparts uses the stack shuffling view mentioned below).

joinparts

The word joinparts takes a pivot element and two lists and joins them together into a single list with the pivot in the middle and the elements of two original lists in the sides.

plit_on_first_element

this method takes a list of numbers (a quote) as the parameters, and pushes back 3 values into the stack. The first value is the first element of list (pivot), second value is a list of elements lesser than this value and third value is a a list containing elements greater than the pivot.Eg: [5 2 3 6 7 8 9] uncons [>] split&will output 5 [2 3] [6 7 8 9]

binrec

binrec expects 4 quotes on top of the stack. The first is termination condition, second is the quote to be evaluated if the termination condition is met, the third quote recursively takes the list on the stack apart, and its output is assembled back by the forth quote. binrec is one of the high level combinators (others are linrec, genrec, tailrec and primrec) that was inherited from Joy and gives the concatenative programming its unique flavour. binrec translates the above as shown below. Notice how the qsort is applied recursively to list1 and list2 (output of split_on_first_element). The result of these and the pivot that was left in stack by split_on_first_element is joined together by joinparts.

[qsort [joinparts [pivot [*list1] [*list2] : [*list1 pivot *list2] view] . [split_on_first_element uncons [>] split&] . [small?] [] [split_on_first_element [list1 list2 : [list1 qsort list2 qsort joinparts] view i] ifte] .

Macros

V provides the word 'view' used to rearrange the position of values in the stack. Most of the stack manipulation words in V are defined using view

Quadratic root in V using the stack manipulating word view [quad-root [a b c : [0 b - b b * 4 a * c * - sqrt + 2 a * /] view i ] .

Exception Handling

V provides a means of handling exceptions using throw and catch.

FFI to Java

An FFI syntax for making use of other libraries loaded in the JVM is also provided in the JVM implementation of V.

[java.util.Date new] java putswill print {Tue Mar 13 19:59:22 IST 2007}

External links

* [http://code.google.com/p/v-language V homepage]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… …   Wikipedia

  • Programming language theory — (commonly known as PLT) is a branch of computer science that deals with the design, implementation, analysis, characterization, and classification of programming languages and programming language features. It is a multi disciplinary field, both… …   Wikipedia

  • Programming Language Design and Implementation — (PLDI) is one of the ACM SIGPLAN s most important conferences. The precursor of PLDI was the Symposium on Compiler Optimization, held July 27–28, 1970 at the University of Illinois at Urbana Champaign and chaired by Robert S. Northcote. That… …   Wikipedia

  • Programming Language for Business — or PL/B is a business oriented programming language originally called DATABUS and designed by Datapoint in the early 1970s as an alternative to COBOL because its 8 bit computers could not fit COBOL into their limited memory, and because COBOL did …   Wikipedia

  • programming language — ➔ language * * * programming language UK US noun [C] ► COMPUTER LANGUAGE(Cf. ↑computer language) …   Financial and business terms

  • programming language — Language Lan guage, n. [OE. langage, F. langage, fr. L. lingua the tongue, hence speech, language; akin to E. tongue. See {Tongue}, cf. {Lingual}.] [1913 Webster] 1. Any means of conveying or communicating ideas; specifically, human speech; the… …   The Collaborative International Dictionary of English

  • Programming Language One — Programming Language One, oft als PL/I (auch PL/1, PL1 oder PLI) abgekürzt ist eine Programmiersprache, die in den 1960er Jahren von IBM entwickelt wurde. Die Bezeichnung PL/1 ist vor allem in Deutschland gebräuchlich. Ursprünglich wurde PL/I… …   Deutsch Wikipedia

  • Programming Language 1 — noun A computer programming language which combines the best qualities of commercial and scientific oriented languages (abbrev PL/1) • • • Main Entry: ↑programme …   Useful english dictionary

  • Programming Language —   [engl.], Programmiersprache …   Universal-Lexikon

  • Programming language specification — A programming language specification is an artifact that defines a programming language so that users and implementors can agree on what programs in that language mean.A programming language specification can take several forms, including the… …   Wikipedia

  • programming language — noun (computer science) a language designed for programming computers • Syn: ↑programing language • Topics: ↑computer science, ↑computing • Hypernyms: ↑artificial language …   Useful english dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”