Sol | 1 Apr 2008 14:27
Picon

Re: cyclone and vim

> I've only ever used emacs with Cyclone.  Don't know if Vim bindings  
> are out there ...

I changed the syntax/c.vim so that it now works for me. The only adjustment
is to comment out 284. The result is attached. To use it, copy it to
~/.vim/syntax/cyclone.vim

Now the filetype for edited cyclone source files has to be set to cyclone.
In vim type

:set ft=cyclone

while editing a source file,

OR add

// vim: ft=cyclone

somewhere in you source file (modeline has to be enabled for this!).

Hope this is useful for some other cyclone user in the future;)

Regards, Simon.
" Vim syntax file
" Language:	C
" Maintainer:	Bram Moolenaar <Bram <at> vim.org>
" Last Change:	2007 Feb 13

(Continue reading)

Sol | 1 Apr 2008 16:48
Picon

Missing Wiki-Pages

Hello,
http://macdonald.cs.umd.edu/wiki/Cyclone%20for%20C%20Programmers
makes references to
http://macdonald.cs.umd.edu/wiki/Memory%20Management%20Via%20Regions
and
http://macdonald.cs.umd.edu/wiki/Libraries
which do not exist. Is this considered an error, or are they just not
written by now?

Regards, Simon.

Sol | 1 Apr 2008 18:50
Picon

tinkering with inner functions

Hello,
while tinkering with inner functions I made some observations. The following
code

int (*Accumulator())(int)
{
    int x = 0;
    int inc(int n)
    {
        return x += n;
    }
    return inc;
}

int main()
{
    _ acc = Accumulator();
    printf("call to x: %d\n", acc(10));
    printf("call to x: %d\n", acc(10));
    return 0;
}

produces a segfault (as expected). I tried to change the storage class of x
to prevent this, with no success. For example

int (*Accumulator())(int)
{
    int  <at>  x = malloc(sizeof(int));
    int inc(int n)
    {
(Continue reading)

Sol | 1 Apr 2008 19:08
Picon

Re: Functional Programming in Cyclone

> The fn.cyc module encodes closures using existential types, following  
> an encoding proposed by Minamide et al. a while back.  If you want to  
> create a closure from a function and its environment you call make_fn 
> (func,env).  If you want to convert a straight function pointer into  
> a closure, you call fp2fn(func).  To call a closure on some argument  
> x, you call apply(closure,x).  The remaining functions are to support  
> composing to fn_t's, currying them, etc.

Thanks for your reply. fp2fn works somehow. But I still do now know how to
give type signatures for such closures (for the case I want to pass them
around).

And I'm still puzzled how to construct/achieve the environment given to
make_fn().

> That said, Cyclone has a functional programming feel, in that it  
> supports local type inference (e.g., you can do let x =   
> someexpression rather than having to declare x's type), and pattern  
> matching on tagged unions and datatypes.  The latter feature is very  
> useful.  I end up using C-style loops rather than tail-recursion, but  
> ML-style type inference and pattern matching.

This is why I was puzzled if Cyclone is more suitable for FP than C is. I'm
evaluating some Languages for there FP capabilities, and one of them should
be suitable for system programming. I'm grateful for any ideas/pointers if
you think that there are better choices than cyclone.

Thanks and best Regards, Simon.

(Continue reading)

Michael Hicks | 2 Apr 2008 00:14
Picon
Favicon

cyclone.thelanguage.org back up

Sorry for the temporary loss of the DNS name; our local DNS was  
failing to cooperate properly!  Let us know if anyone has further  
issues reaching the site.

-Mike

Nikhil Swamy | 4 Apr 2008 17:38
Picon
Favicon

Re: tinkering with inner functions

> Further more I realized that using printf(...) in the
> inner function gives the same compile error ("Toc did not examine an
> inserted check: (x | printf)"). What restrictions do apply for inner
> functions, or what are they meant for? Are they useful in any way?  
> Or are
> they a broken feature?

I believe inner functions are currently broken ... apologies.

> Further more I realized that the  <at> region qualifier is deprecated,  
> does it
> still worker as documented? Is documentation for  <at> effect available?

A pointer in Cyclone can be qualified by a set of region names (the  
effect), rather than just a single name. Where previously we used an  
"outlives" relation on region names to do subtyping, we now use a  
subset relation on effects. There's more information about this in  
the manual, but it was not explicit about the relationship between  
 <at> effect and  <at> region. I've now added a couple of sentences about this.  
The short version is that you can always use  <at> effect in place of  
 <at> region.

For the full story:

http://cyclone.thelanguage.org:80/wiki/Type-Checking%20Regions
(the part about "Subtyping and Effect Qualifiers")

and

http://cyclone.thelanguage.org/wiki/Pointers%20with%20Restricted% 
(Continue reading)


Gmane