v5 syntax changes

19 views
Skip to first unread message

Ostap Cherkashin

unread,
May 18, 2012, 4:09:28 PM5/18/12
to band...@googlegroups.com
we are about to introduce some very exciting new functionality:
* function calls - calling functions from within the bandicoot
* modules - keeping things encapsulated
* attribute sets - making type composition easier

obviously these new features impact the bandicoot language one way or another. in order to keep the syntax consistent with the new features it was necessary to perform some syntax adjustments. i've implemented these adjustments on top of the current functionality in the origin/syntax branch at bandilab.org.

if you want to see how your programs will look like with the proposed changes, you can use the program converter (bin/convert). while working with the branch keep in mind that all the tests and data is checked in using the v4 notations and prior to using the branch you need to run 'ctl convert' (only once).

here is a brief summary of changes:

1) operators and function calls are prefix, e.g. "opname (arg1) (arg2) .. (argN)" where braces required only for compound statements. here are some examples:
---
join books authors
union books newBooks
minus books topAuthors
summary minPrice = (min price 0.0) books
summary maxPrice = (min price 0.0) books titles
project firstName, lastName users
rename id = login users
extend newPrice = price * 1.10 books
select price < 10.0 books
myFunc books "penguin"
---
infix versions of the union, minus, and join operators are also available along with the corresponding assignment shortcuts (+, -, *, +=, -=, *= accordingly), but program converter will replace everything with the prefix statements.

2) new keyword "type" and the simplified syntax for relational type declarations
---
type Books {title string, pages int, price real}
---
essentially the relational type is enclosed within the curly braces and there are no more colons and "rel" keyword. this change prepares for the attribute sets and makes declarations less heavy.  

3) new keyword "var"
---
var shelf Books;
var myBooks = select author == "me" books;
---
all variables declarations should start with "var".

4) new keyword "void"
--
fn Append(b Books) void {...}
---
if a function does not return anything it should specify "void".

your feedback and review comments are welcome!

- ostap

Cezar Lotrean

unread,
May 18, 2012, 4:38:23 PM5/18/12
to band...@googlegroups.com

This is very cool stuff Ostap.


Julius Chrobak

unread,
May 20, 2012, 8:10:17 AM5/20/12
to band...@googlegroups.com
hello all,

This is indeed a great set of changes and I'm looking forward to see it all working!

I've had a look at the branch and I have the following comments:
1) The convert utility removes the comments as well. Not sure if this can be easily fixed but ideally it would leave the comments as they are.

2) I get the following error after the usage information when I run bandicoot (on Mac OS X 10.7.3) without any params: [system error: 'Bad executable (or shared library)']

3) After merging to the master we need to make sure there is a comprehensive description on how to use the convert utility. There several things people would need to be careful about:
    a) we're introducing a new reserved words in the language and this can cause a lot of troubles if they are already in use (for example keyword "type" could someone already use and an attribute name)
    b) it is a must to convert not only an existing source file but also the source file stored (copied) into an existing volume


I have no comments to the code changes. I think they are good to go to the master.

Julius.

Julius Chrobak

unread,
May 20, 2012, 8:52:38 AM5/20/12
to band...@googlegroups.com
There is one point I forgot to mention. The type conversions are defined in the following form:

| TK_INT '(' prim_expr ')' 
| TK_REAL '(' prim_expr ')'
| TK_LONG '(' prim_expr ')'

I was thinking to modify this to:

| '(' TK_INT prim_expr ')' 
| '(' TK_REAL prim_expr ')'
| '(' TK_LONG prim_expr ')'

In other words the usage would change from
… extend x = real(y) ….
to
… extend x = (real y) ….


This would be consistent with the overall concept of the prefix form including the summary functions (min, max, add, and avg).

Julius.

Ostap Cherkashin

unread,
May 20, 2012, 2:15:22 PM5/20/12
to band...@googlegroups.com
indeed, i've implemented the primitive type conversion change. i've also implemented a small adjustment to the multiple declarations syntax: the shorthand version is now "x y real" (as opposed to the "x, y real"), this ensures compatibility with the attribute sets.

with regard to the rest of the points:

1.) proper comment handling is a task on its own. i tried to build it but i feel like the approach i took is potentially full of bugs (so i would not merge it). may be someone has a better idea:

convert_comments.patch

Ostap Cherkashin

unread,
May 21, 2012, 11:32:58 AM5/21/12
to band...@googlegroups.com
(2) was related to uninitialized errno. i reran all the tests, converted programs and data, and merged the changes to the master. we will wrap these changes into an intermediate release (v5).

- ostap

 
2.) i don't get anything like this on a similar system, see below for my system info.

3.) i've added compatibility notes to the README file, and i also integrated the convert program into the main executable ("bandicoot convert") and created a short documentation for it.

- ostap

---
system info:

pacman|bandicoot% uname -a
Darwin pacman.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64

pacman|bandicoot% which gcc
/usr/bin/gcc

pacman|bandicoot% gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
---
<convert_comments.patch>

Reply all
Reply to author
Forward
0 new messages