[LLVMdev] My LLVM Project
Talin
viridia at gmail.com
Tue Sep 15 09:32:00 PDT 2009
Renato Golin wrote:
> 2009/9/15 Talin <talin at acm.org>:
>
>> For example, here's what the "Iterator" interface looks like:
>>
>> interface Iterator[%T] {
>> def next -> T or void;
>> }
>>
>
> So this would be something like:
>
> template <class T>
> virtual class Iterator {
> T next(); // or void?
> };
>
> So the power of having two types of return parameters is that you save
> function calls (hasNext())?
>
There are other benefits as well. Having disjoint types makes library
APIs cleaner - often a function will need to return either a result, or
an error code. In C++, this has to be handled either via a reference
parameter (which is inefficient because the compiler's live variable
analysis can't determine if the value was assigned or not) or by
returning a struct.
>> def sum(nums:int...) -> int {
>> var sum = 0;
>> for i in nums {
>> sum += i;
>> }
>> return sum;
>> }
>>
>
> I see you don't have types for variables, only for containers,
> templates and functions. And yet you say your language is
> statically-typed. If you do:
>
The type of a variable is optional - if omitted, it is deduced from the
initializer.
> var foo = 10; // I'd presume it's an int
> foo /= 3;
>
> Would foo become a float?
>
> foo /= 1e200;
>
> Would it become a double?
>
> What happens if you pass foo as an int, and inside the function it
> becomes a double (without your consent, by a combination of
> parameters) and you try to return it as an int?
>
>
>
>> 'classify' is like a switch statement, except that the cases are types
>> rather than values. It works with both disjoint types and polymorphic
>> types, similar to what is seen in Scala and various functional languages
>> such as OCaml. The variables in the individual 'as' clauses are never in
>> scope unless the assignment to that variable actually succeeds, so
>> there's no chance of seeing an uninitialized variable.
>>
>
> Is it run-time or compile-time? The former is Java's insanceof/C++
> RTTI, the later has not many uses...
>
>
It's like Java's "instanceof", i.e. a runtime type test.
>> In any case, I don't want to go on about this too long - at least not
>> until the compiler is in better shape to be shown to the world. I still
>> need to work on closures, reflection, garbage collection, interface
>> proxies, stack dumps, debug info, and a bunch of other stuff. (There's a
>> Google code project for it, but I'm not encouraging people to go there
>> until I have more of the language finished.)
>>
>
> I think it's great to write compilers to learn how languages work (I'm
> doing my own too).
>
> My points about the language:
>
> First, It's much more like a cross between Python/Perl and Java than
> C++. It's not strongly typed and yet it use generic programming. As
> long as it's not creating *types* with templates (like C++) but
> creating only generic algorithms (like Java), it's ok.
>
It's not meant to "look" like C++ - it's meant to occupy the same
ecological niche. I have many years of experience programming in Java,
C# and Python, and I'm happy using those languages to write things like
web servers and desktop applications. But there are some tasks which I
*wouldn't* use those languages for - XBox games, MPEG decoders,
AudioUnits, signal processing, and so on. For those kinds of tasks, I
would normally use C++ - but over the years I have collected hundreds of
gripes with C++, which I'd like to fix.
> It has too much syntactic sugar and names changed for no apparent
> reason, it drives the user away from using your language. A good deal
> of Java's success is because they used a syntax very similar to C++.
>
> My (very personal) point of view is that, if you're not bringing
> anything new, help the others that are instead of re-inventing the
> wheel. But again, if your point is (as mine) to learn, well done! It's
> much better than my own language! ;)
>
>
I've only shown a small part of what I have. This forum is not the place
for language advocacy, I don't want to start a discussion on the merits
of my language or any other. I'm absolutely convinced that I have
something to contribute, and I'm going to forge ahead despite the
naysayers :)
Mainly, I just wanted to share with the LLVM community how I am using
LLVM, and I don't want the topic to stray too far from that.
> cheers,
> --renato
>
> Reclaim your digital rights, eliminate DRM, learn more at
> http://www.defectivebydesign.org/what_is_drm
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
More information about the llvm-dev
mailing list