The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
The Design of Brne

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Christian Neukirchen

Posts: 188
Nickname: chris2
Registered: Mar, 2005

Christian Neukirchen is a student from Biberach, Germany playing and hacking with Ruby.
The Design of Brne Posted: Jun 17, 2006 9:55 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Christian Neukirchen.
Original Post: The Design of Brne
Feed Title: chris blogs: Ruby stuff
Feed URL: http://chneukirchen.org/blog/category/ruby.atom
Feed Description: a weblog by christian neukirchen - Ruby stuff
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Christian Neukirchen
Latest Posts From chris blogs: Ruby stuff

Advertisement

Values

Brne only knows one type of value: bi-relations that sometimes can be ordered. Imagine this as a multimap (i.e. keys don’t have to be unique) of keys to values. Relations map atoms (which aren’t directly accessible from the language) to other atoms. The literal 42 would, for example, really be a relation of one tuple that maps 42 to 42. Atoms can be numbers, strings, symbols (which often serve as primary keys) or the special value nil, maybe things like dates will be added.

Operators

Operators are functions of arity 0 (mediadic), 1 (monadic) or 2 (dyadic). All dyadic operators are used infix and consist of ASCII non-letter symbols, all mediadic and monadic operators use prefix and can either consist of non-letter symbols or only letters and digits (usually, one would call them a “method” or a “function” then, but Brne only knows operators).

The result of an operation is another relations. Internally, this works using a lazily evaluated generator: every operator implements a certain set of operations: reset, which resets the generator; next? which returns a boolean value if there is another element to be generated and next, which returns this element. Therefore, operators are very much like forward iterators that embody a calculation.

All operators in Brne are purely functional, that is, they don’t have side effects. This allows for excellent parallelism: every argument of the operator can be evaluated independently.

A few example operators would be (this is not written into stone yet):

  • nil: Always returns nil.

  • id: Returns the identity relation that maps every key as value.

  • keys a: Returns the “left column” of the relation a.

  • values a: Returns the “right column” of the relation a.

  • flip a: Returns the relation a with keys and values exchanged.

  • a -> b: Creates a relation of the first key of a to the first key of b.

  • a ++ b: Unifies the relations a and b.

  • a . b: Creates a new relation that maps the values of a to the keys of b, that is, a semi-join.

  • a = b: Selects the tuples of a whose keys are keys of b.

There will be more operators for basic arithmetics, comparision and SQLish aggregates like sum, avg, min and max.

Additionally, there are adverbs that modify the behavior of an operator. So far, the only adverb is ', which works like this: a op' b becomes (flip a) op (flip b). That, e.g. allows for easy selection by value. As special syntax, a’ generally is (flip a).

I’ve already written a parser in Racc and some of the operators. I also have a QDBM based datastore and hacked RbTree for in-memory representation. Now, it’s all a matter of putting these things together, converting some database queries and watching which parts of the prototype are too slow.

Then, I can start modeling this evaluation scheme to C and connect it with libsew.

NP: Syd Matters feat. Ane Brun—Little Lights

Read: The Design of Brne

Topic: A Ruby HOWTO: Writing A Method That Uses Code Blocks Previous Topic   Next Topic Topic: A Ruby HOWTO: Writing A Method That Uses Code Blocks

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use