Bill Hart wrote:
> Hi,
>
> Thanks, I managed to get it going with LLVM 3.1. The messages I posted
> appear with LLVM 3.2, as I am sure you already realised.
>
> I have to say, I am loving Crack programming so far. I hooked it up to the
> fmpz module from flint (
http://flintlib.org) using primitive bindings to
> give myself bignums (it uses GMP for anything over 1 limb and machine longs
> otherwise) and coded up some simple factorial and fibonacci number
> generators and am quite impressed that I can get very close to the speed of
> the native GMP factorial and fibonacci functions (using some easy but not
> stupid algorithms of course). So, that confirms that the FFI is working
> really well.
>
> I'm also loving the operator overloading.
>
> I don't know if you are interested in user feedback at this point, but here
> are some observations I have already made. Any suggestions are welcome.
>
> * I had an issue using a C string function via the FFI. It returns a C
> string which the user is required to clean up. I was unclear on whether
> Crack would know to clean it up if I placed that string inside a Crack
> Buffer or something similar.
That depends on the buffer. See lib/crack/lang.crk
>
> * I also had some difficulties figuring out how to convert such a C string
> into a Crack string. The documentation seems to indicate that strings in
> Crack should be viewed as immutable.
That depends. If you have a null-terminated string 's', you can do String(s).
This will copy the buffer. You can also use String(s, num_bytes, false) to
create a copy of the backing string or String(s, num_bytes, true) if you want
the new object to take ownership of the original memory (and release it with
free()).
>
> * I was not able to understand the documentation on the Formatter protocol
> and on ManagedBuffers. I don't really know what either of these do or how
> to use them. This is probably just a concept which is familiar to other
> programming language designers, but not to me.
>
> * Some of the Writer examples in the docs don't seem to compile.
>
> * I am really missing tuples and tuple unpacking. Are there plans to add
> them? (I know the former can be created using a class.)
Not as such, but I've long considered how best to add anonymous structures to
the language which would serve a similar function. My current thinking is
something along the lines of this:
struct[String name, int val] getItem() { return {'foo', 100}; }
item := getItem();
cout `$(
item.name)\n`;
But this is far from definite.
>
> * I am really missing dependent types, e.g. types parameterised by
> integers, strings and symbols. (C++ does the former, D allows strings, for
> example.) Are there any plans to add these?
Not at this time, but I'd be interested to hear your use case for them.
>
> * I wasn't clear on how to create and precompile my own crack modules. I
> guess this is not implemented yet, but planned?
You can't do this at the module level. You can run "crackc" on a script to
package the script and all of its dependencies into a single executable.
The main thing I've been working on over the past year has been module
caching. Basically, the first time you compile a module, the executor creates
cache files for that module (an LLVM bitcode file and a Crack meta-data file).
From then on, the cache files are imported instead of recompiling the module
(as long as its source and dependencies haven't changed).
Caching isn't quite the same as pre-compiling. You could distribute the cache
files, but there's no guarantee that a user would be able to use them the way
they want, in the long-run there may be many cache file formats, and in fact
LLVM bit-code currently isn't platform indepdendent. The distribution mode
for Crack modules really is intended to be the module source.
>
> * strcpy seems to no longer be in runtime but is referred to as such in the
> docs.
That's odd, it seems to still be there for me.
import crack.runtime strcpy;
strcpy(byteptr(0), byteptr(0));
>
> * I was disappointed that Crack was unable to infer types used in templated
> classes. E.g. if I create class Pair[FirstType, SecondType], it seems that
> I cannot do Pair(12, 14) and have it infer that FirstType is int and
> SecondType is int (or whatever 12 and 14 are). Are there plans to add this?
Nothing concrete, but I agree that this would be useful. It's a complicated
problem that I haven't given much thought to.
>
> That's all I can think of for now. Anyway, I had a lot of fun last night
> playing with Crack-lang.
>
> Did I see somewhere that someone is planning a repl?
Someone worked on one a while ago, but I had some issues with some of the
implemementation details and we were unable to come to a resolution on them
before he moved on.
I'd like very much to see it happen, but it needs an owner with the necessary
skills, motivation and patience to put up with the rest of us ;-)
I'm glad to hear you enjoyed the language!
And thanks for the feedback, I'll try to fix some of the breakage in the docs.
Government is not reason, it is not eloquence; it is force. Like fire, it
is a dangerous servant and a fearsome master. - George Washington
=============================================================================