www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Targeting C

reply Tim Matthews <tim.matthews7 gmail.com> writes:
While C may be not much from assembly and C++ a mess. C with a strapped 
on GC can have full power, portability which just leaves the programmer 
to please.

Some of spotted this and instead of compiling directly, they output C 
code. Some examples of this are:

Bitc. Combines the flexibility, rich, safe of modern day functional 
languages with power of C. http://www.bitc-lang.org/


code using the GObject library. http://live.gnome.org/Vala

And 2 more recent ones:

OOC. I quite like how this one myself personally. http://ooc-lang.org/about

Zimbu. Quote from the zimbu page: "It has to run on most systems, 
anything with a C compiler, so D is out" http://www.zimbu.org/
Oct 21 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Tim Matthews:

 OOC. I quite like how this one myself personally. http://ooc-lang.org/about
Type of arguments can be stated once: Vector3f: class { x, y, z : Float init: func(x, y, z : Float) { this x = x // 'this' is called 'self' in some other languages this y = y this z = z } } It doesn't need the is() when you test for type equality: print: func <T> (arg: T) { if(T == Int) { printf("%d\n", arg as Int) // 'as' allow casting } else if(T == String) { printf("%s\n", arg as String) } } Uses a syntax better than the D foreach: list := ArrayList<Int> new() for(i in 0..10) list add(i) // oh yeah no needs for brackets for(i in list) printf("%d\n") And I have omitted some other handy features. There's something to learn for D too :-) Bye, bearophile
Oct 22 2009
parent reply =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
bearophile wrote:
 Tim Matthews:
 
 OOC. I quite like how this one myself personally. http://ooc-lang.org/about
Type of arguments can be stated once: Vector3f: class { x, y, z : Float init: func(x, y, z : Float) { this x = x // 'this' is called 'self' in some other languages this y = y this z = z } } It doesn't need the is() when you test for type equality: print: func <T> (arg: T) { if(T == Int) { printf("%d\n", arg as Int) // 'as' allow casting } else if(T == String) { printf("%s\n", arg as String) } } Uses a syntax better than the D foreach: list := ArrayList<Int> new() for(i in 0..10) list add(i) // oh yeah no needs for brackets for(i in list) printf("%d\n") And I have omitted some other handy features. There's something to learn for D too :-) Bye, bearophile
Personally, I like this: foreach (i; 0..10) list ~= i; more. :)
Oct 22 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Pelle Månsson:

 Personally, I like this:
 foreach (i; 0..10) list ~= i;
 more. :)
While I like this more: for (i in 0 .. 10) list ~= i; Bye, bearophile
Oct 22 2009
parent reply Chris Nicholson-Sauls <ibisbasenji gmail.com> writes:
bearophile wrote:
 Pelle MÃ¥nsson:
 
 Personally, I like this:
 foreach (i; 0..10) list ~= i;
 more. :)
While I like this more: for (i in 0 .. 10) list ~= i; Bye, bearophile
I prefer this (Scala): list = list ++ (0 to 10) Okay, that's not really fair. The direct port to Scala would be more like: for { i <- 0 to 10 } list :::= List(i) Ultimately, syntax only really matters greatly where it provides some significant advantage or detours from some significant disadvantage. Kinda like the '$' in array indices. Early on in D, we had no such creature, but I threw my support fully behind it because of my prior experience with ColdC (and λμ, etc) and its use of the same syntax. Generally speaking, when a given language has an inordinate amount of syntax in some activity, it is probably a good sign that activity is uncommon when the language is properly applied. Conversely, a terse compact syntax is a good sign that's common usage. Depends on "genre"... and now I'm ranting and have no idea why. -- Chris Nicholson-Sauls
Oct 23 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
Oct 23 2009
parent reply Yigal Chripun <yigal100 gmail.com> writes:
On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
Oct 23 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
Oct 23 2009
next sibling parent reply Bill Baxter <wbaxter gmail.com> writes:
On Fri, Oct 23, 2009 at 5:13 AM, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10));
While we're not on the subject.... "Iota" is right up there with "inSitu". I know it has a precedent elsewhere, but it sounds about as user friendly as monads. It just sounds like the language it trying to be snooty. Like "if you don't even know what iota is, you're clearly not qualified to join our little D club. Maybe you should try Java... or Logo". Compare that to Python where it's called "range", something every Joe the Programmer can certainly grok without having to get a Greek to English dictionary. --bb
Oct 23 2009
next sibling parent reply Yigal Chripun <yigal100 gmail.com> writes:
On 23/10/2009 17:51, Bill Baxter wrote:
 On Fri, Oct 23, 2009 at 5:13 AM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10));
While we're not on the subject.... "Iota" is right up there with "inSitu". I know it has a precedent elsewhere, but it sounds about as user friendly as monads. It just sounds like the language it trying to be snooty. Like "if you don't even know what iota is, you're clearly not qualified to join our little D club. Maybe you should try Java... or Logo". Compare that to Python where it's called "range", something every Joe the Programmer can certainly grok without having to get a Greek to English dictionary. --bb
Ranges are already part of the compiler because of foreach, can we also add language support for Range literals? i.e (1..10) => range(1, 10) //(I'm using BB's much better name) [1..10] => array(range(1, 10)) it already is supported is foreach, isn't it? foreach (i; 1..10) {...}
Oct 23 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Yigal Chripun:

 Ranges are already part of the compiler because of foreach, can we also 
 add language support for Range literals?
In both iota and other possible implementations I'd like the arguments used by Python range/xrange, they are optimal, and better than the currently ones used by iota. And being ranges lazy and eager (strict) so common, I may want both versions, so I don't need array(iota(...)) (all this is present in my dlibs). What about xiota for the lazy version? Or maybe aiota for the eager version? :-) Bye, bearophile
Oct 23 2009
parent reply Yigal Chripun <yigal100 gmail.com> writes:
On 23/10/2009 18:29, bearophile wrote:
 Yigal Chripun:

 Ranges are already part of the compiler because of foreach, can we
 also add language support for Range literals?
In both iota and other possible implementations I'd like the arguments used by Python range/xrange, they are optimal, and better than the currently ones used by iota. And being ranges lazy and eager (strict) so common, I may want both versions, so I don't need array(iota(...)) (all this is present in my dlibs). What about xiota for the lazy version? Or maybe aiota for the eager version? :-) Bye, bearophile
Hell no. This is why I hate certain programming languages. if you are trying to obfuscate the language than why not just define: rtqfrdsg and fdkjtkf as the function names? names are important and they must be readable (in English. latin/greek/hindu/klingon/etc are not accepted). I don't care if I need to type ten letters instead of just five if later on I can understand immediately what the code does instead of spending half an hour reading the (outdated) documentation if I even bothered to write one.
Oct 23 2009
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Yigal Chripun:

 Hell no. This is why I hate certain programming languages.
 if you are trying to obfuscate the language than why not just define:
 rtqfrdsg and fdkjtkf as the function names?
Don't be silly. In my dlibs "xsomething" are the lazy functions, and "something" are the strict ones. That's not obfuscated, you need seconds to learn a single easy rule. Bye, bearophile
Oct 23 2009
parent reply =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
bearophile wrote:
 Yigal Chripun:
 
 Hell no. This is why I hate certain programming languages.
 if you are trying to obfuscate the language than why not just define:
 rtqfrdsg and fdkjtkf as the function names?
Don't be silly. In my dlibs "xsomething" are the lazy functions, and "something" are the strict ones. That's not obfuscated, you need seconds to learn a single easy rule. Bye, bearophile
I think the complaint was not as much about the x as the iota. Seriously, iota? However, I like the array(range(0,10)) where range is always lazy, and array forces eagerness, better than separate xrange and range functions.
Oct 23 2009
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Pelle Månsson wrote:
 bearophile wrote:
 Yigal Chripun:

 Hell no. This is why I hate certain programming languages.
 if you are trying to obfuscate the language than why not just define:
 rtqfrdsg and fdkjtkf as the function names?
Don't be silly. In my dlibs "xsomething" are the lazy functions, and "something" are the strict ones. That's not obfuscated, you need seconds to learn a single easy rule. Bye, bearophile
I think the complaint was not as much about the x as the iota. Seriously, iota? However, I like the array(range(0,10)) where range is always lazy, and array forces eagerness, better than separate xrange and range functions.
Orthogonality for the win. Andrei
Oct 23 2009
parent Leandro Lucarella <llucax gmail.com> writes:
Andrei Alexandrescu, el 23 de octubre a las 13:06 me escribiste:
 Pelle MÃ¥nsson wrote:
bearophile wrote:
Yigal Chripun:

Hell no. This is why I hate certain programming languages.
if you are trying to obfuscate the language than why not just define:
rtqfrdsg and fdkjtkf as the function names?
Don't be silly. In my dlibs "xsomething" are the lazy functions, and "something" are the strict ones. That's not obfuscated, you need seconds to learn a single easy rule. Bye, bearophile
I think the complaint was not as much about the x as the iota. Seriously, iota? However, I like the array(range(0,10)) where range is always lazy, and array forces eagerness, better than separate xrange and range functions.
Orthogonality for the win.
Sometimes "practicality beats purity" :) But I don't really care that much about this one... -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- DIEZ "PUNGAS" MENOS -- Crónica TV
Oct 23 2009
prev sibling parent Yigal Chripun <yigal100 gmail.com> writes:
On 23/10/2009 19:49, Pelle Månsson wrote:
 bearophile wrote:
 Yigal Chripun:

 Hell no. This is why I hate certain programming languages.
 if you are trying to obfuscate the language than why not just define:
 rtqfrdsg and fdkjtkf as the function names?
Don't be silly. In my dlibs "xsomething" are the lazy functions, and "something" are the strict ones. That's not obfuscated, you need seconds to learn a single easy rule. Bye, bearophile
I think the complaint was not as much about the x as the iota. Seriously, iota? However, I like the array(range(0,10)) where range is always lazy, and array forces eagerness, better than separate xrange and range functions.
first thing xsomthing *is* silly and I agree with andrei and pelle about having an array function that forces eagerness. but more generally speaking, each individual part can be rationalized like xsomething is lazy, iota generates a lazy range, etc.. but combined you get meaningless letters.. xaiota? rule 1 of programming - code is read 1000 times more then written. today at the age of terabyte HDDs writing strcmp instead of string_compare or stringCompare (depends on your love for camels) is absolutely ridiculous.
Oct 23 2009
prev sibling parent =?ISO-8859-1?Q?=22J=E9r=F4me_M=2E_Berger=22?= <jeberger free.fr> writes:
Yigal Chripun wrote:
 On 23/10/2009 18:29, bearophile wrote:
 Yigal Chripun:

 Ranges are already part of the compiler because of foreach, can we
 also add language support for Range literals?
In both iota and other possible implementations I'd like the arguments used by Python range/xrange, they are optimal, and better than the currently ones used by iota. And being ranges lazy and eager (strict) so common, I may want both versions, so I don't need array(iota(...)) (all this is present in my dlibs). What about xiota for the lazy version? Or maybe aiota for the eager version? :-) Bye, bearophile
=20 =20 Hell no. This is why I hate certain programming languages. if you are trying to obfuscate the language than why not just define: rtqfrdsg and fdkjtkf as the function names? =20 names are important and they must be readable (in English.=20 latin/greek/hindu/klingon/etc are not accepted). I don't care if I need=
=20
 to type ten letters instead of just five if later on I can understand=20
 immediately what the code does instead of spending half an hour reading=
=20
 the (outdated) documentation if I even bothered to write one.
Note that both "iota" and "in situ" are in the "Collins Cobuild=20 English Language Dictionary". Here are their definitions: "in situ" is used to describe something that remains in its original=20 or appropriate place while work is done on it. "iota" An iota of something is an extremely small amount of it. Therefore, both should be considered acceptable English words.=20 However whereas "inSitu" says exactly what it means, I'm not so sure=20 about "iota" Jerome PS: For those who don't know, the Collins Cobuild is special in that=20 it is built using statistics on word usage. They choose which words=20 to include based on how frequently those words are used in common=20 English. --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Oct 23 2009
prev sibling next sibling parent Leandro Lucarella <llucax gmail.com> writes:
Bill Baxter, el 23 de octubre a las 08:51 me escribiste:
 list ~= array(iota(0, 10));
While we're not on the subject.... "Iota" is right up there with "inSitu". I know it has a precedent elsewhere, but it sounds about as user friendly as monads. It just sounds like the language it trying to be snooty. Like "if you don't even know what iota is, you're clearly not qualified to join our little D club. Maybe you should try Java... or Logo". Compare that to Python where it's called "range", something every Joe the Programmer can certainly grok without having to get a Greek to English dictionary.
Thanks for mention this, now I don't feel *that* idiotic to have to go and search what iota means every time I see it =) -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Did you know the originally a Danish guy invented the burglar-alarm unfortunately, it got stolen
Oct 23 2009
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Bill Baxter wrote:
 On Fri, Oct 23, 2009 at 5:13 AM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org> wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10));
While we're not on the subject.... "Iota" is right up there with "inSitu". I know it has a precedent elsewhere, but it sounds about as user friendly as monads. It just sounds like the language it trying to be snooty. Like "if you don't even know what iota is, you're clearly not qualified to join our little D club. Maybe you should try Java... or Logo". Compare that to Python where it's called "range", something every Joe the Programmer can certainly grok without having to get a Greek to English dictionary.
Given that "range" is already taken, what name do you think would work best? (I sometimes deliberately prefer less-used names because the more used ones often come with baggage and ambiguities (as is the case with "range"). Case in point, "in-situ" is more informative than "in-place" because the former suggests emplacement of a substructure within a larger structure. So to me an "in-situ" class member inside a class has a clear meaning that the member sits right there within the class. But anyhow I will use in-place from now on.) Andrei
Oct 23 2009
parent reply Leandro Lucarella <llucax gmail.com> writes:
Andrei Alexandrescu, el 23 de octubre a las 11:09 me escribiste:
 Bill Baxter wrote:
On Fri, Oct 23, 2009 at 5:13 AM, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
Yigal Chripun wrote:
On 23/10/2009 13:02, bearophile wrote:
Chris Nicholson-Sauls:

I prefer this (Scala):
list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10));
While we're not on the subject.... "Iota" is right up there with "inSitu". I know it has a precedent elsewhere, but it sounds about as user friendly as monads. It just sounds like the language it trying to be snooty. Like "if you don't even know what iota is, you're clearly not qualified to join our little D club. Maybe you should try Java... or Logo". Compare that to Python where it's called "range", something every Joe the Programmer can certainly grok without having to get a Greek to English dictionary.
Given that "range" is already taken, what name do you think would work best? (I sometimes deliberately prefer less-used names because the more used ones often come with baggage and ambiguities (as is the case with "range"). Case in point, "in-situ" is more informative than "in-place" because the former suggests emplacement of a substructure within a larger structure. So to me an "in-situ" class member inside a class has a clear meaning that the member sits right there within the class. But anyhow I will use in-place from now on.)
I don't see "range" taken inside the range module. I think it even makes sense, iota() is the more primitive range ever, so why don't just call it range()? :) Anyway, I think it makes perfect sense to have the compiler translating x..y to a iota/range(x, y). -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- CAROZO CON FARINGITIS -- Crónica TV
Oct 23 2009
parent =?UTF-8?B?UGVsbGUgTcOlbnNzb24=?= <pelle.mansson gmail.com> writes:
Leandro Lucarella wrote:
 Andrei Alexandrescu, el 23 de octubre a las 11:09 me escribiste:
 Bill Baxter wrote:
 On Fri, Oct 23, 2009 at 5:13 AM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org> wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10));
While we're not on the subject.... "Iota" is right up there with "inSitu". I know it has a precedent elsewhere, but it sounds about as user friendly as monads. It just sounds like the language it trying to be snooty. Like "if you don't even know what iota is, you're clearly not qualified to join our little D club. Maybe you should try Java... or Logo". Compare that to Python where it's called "range", something every Joe the Programmer can certainly grok without having to get a Greek to English dictionary.
Given that "range" is already taken, what name do you think would work best? (I sometimes deliberately prefer less-used names because the more used ones often come with baggage and ambiguities (as is the case with "range"). Case in point, "in-situ" is more informative than "in-place" because the former suggests emplacement of a substructure within a larger structure. So to me an "in-situ" class member inside a class has a clear meaning that the member sits right there within the class. But anyhow I will use in-place from now on.)
I don't see "range" taken inside the range module. I think it even makes sense, iota() is the more primitive range ever, so why don't just call it range()? :)
This was my thought as well. I don't know if it fares well in the ambiguity department, though.
Oct 23 2009
prev sibling parent reply =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
Oct 23 2009
next sibling parent Max Samukha <spambox d-coding.com> writes:
On Fri, 23 Oct 2009 18:16:29 +0200, Pelle M?nsson
<pelle.mansson gmail.com> wrote:

Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
A sequence of integral numbers. I guess the name comes from APL.
Oct 23 2009
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Pelle Månsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota Irony minded. I'm destroyed. Andrei
Oct 23 2009
next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Fri, 23 Oct 2009 12:50:34 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail erdani.org> wrote:

 What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota Irony minded. I'm destroyed.
Hm... this is slightly off topic, but that function signature is absolutely horrendous (in fact, I thought you linked to the wrong place at first). Isn't there any way to avoid putting half the type construction as the return value? Do all range-creating functions suffer from this problem? Maybe it's just a ddoc problem. -Steve
Oct 23 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Steven Schveighoffer wrote:
 On Fri, 23 Oct 2009 12:50:34 -0400, Andrei Alexandrescu 
 <SeeWebsiteForEmail erdani.org> wrote:
 
 What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota Irony minded. I'm destroyed.
Hm... this is slightly off topic, but that function signature is absolutely horrendous (in fact, I thought you linked to the wrong place at first). Isn't there any way to avoid putting half the type construction as the return value? Do all range-creating functions suffer from this problem? Maybe it's just a ddoc problem.
I wanted to use auto, but ddoc cannot document functions with auto returns. Andrei P.S. It looks like TDPL will scream today through the 100,000 words barrier (at 97,781 words now, see and track at www.erdani.com). When that happens, I'll celebrate by making another excerpt available online.
Oct 23 2009
next sibling parent reply Ary Borenszweig <ary esperanto.org.ar> writes:
Andrei Alexandrescu wrote:
 Steven Schveighoffer wrote:
 On Fri, 23 Oct 2009 12:50:34 -0400, Andrei Alexandrescu 
 <SeeWebsiteForEmail erdani.org> wrote:

 What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota Irony minded. I'm destroyed.
Hm... this is slightly off topic, but that function signature is absolutely horrendous (in fact, I thought you linked to the wrong place at first). Isn't there any way to avoid putting half the type construction as the return value? Do all range-creating functions suffer from this problem? Maybe it's just a ddoc problem.
I wanted to use auto, but ddoc cannot document functions with auto returns.
Is it too hard to fix that? I think ddoc works before the semantic pass so the return type is null by then, but it isn't very hard to see a "if type.next != null" in the source code... I say it because I also find horrendous the signature. And what's more, it's hard to find the word "iota" there. I also think "iota" is an awful name for that function.
Oct 23 2009
parent Brad Roberts <braddr bellevue.puremagic.com> writes:
On Fri, 23 Oct 2009, Ary Borenszweig wrote:

 Andrei Alexandrescu wrote:
 Steven Schveighoffer wrote:
 On Fri, 23 Oct 2009 12:50:34 -0400, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org> wrote:
 
 What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota Irony minded. I'm destroyed.
Hm... this is slightly off topic, but that function signature is absolutely horrendous (in fact, I thought you linked to the wrong place at first). Isn't there any way to avoid putting half the type construction as the return value? Do all range-creating functions suffer from this problem? Maybe it's just a ddoc problem.
I wanted to use auto, but ddoc cannot document functions with auto returns.
Is it too hard to fix that? I think ddoc works before the semantic pass so the return type is null by then, but it isn't very hard to see a "if type.next != null" in the source code... I say it because I also find horrendous the signature. And what's more, it's hard to find the word "iota" there. I also think "iota" is an awful name for that function.
It'd be really sweet if someone stepped up to work on ddoc with the same gusto that Don has been on other parts of DMD. IMHO, without having done enough code study, ddoc should be split off into a separate executable that shared the first stages of DMD. I'm not sure that'd help it act different where it needs to act different, but it'd certainly be an interesting exercise to get more data about how re-usable parts of DMD are. Alternatively, it'd also be interesting to explore making it _really_ separate and use the new -X output and build docs completely off that. Later, Brad
Oct 23 2009
prev sibling parent reply Max Samukha <spambox d-coding.com> writes:
On Fri, 23 Oct 2009 13:08:06 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:

I wanted to use auto, but ddoc cannot document functions with auto returns.

Andrei
When I need to hack around an 'auto' bug, I sometimes factor out the return type to a template: template IotaRet(B, E, S = size_t) { alias Take!(Sequence!("a.field[0] + n * a.field[1]", Tuple!(CommonType!(B, E), S))) IotaRet; } IotaRet!(B, E, S) iota(B, E, S)(B begin, E end, S step) {} IotaRet!(B, E) iota(B, E)(B begin, E end) {}
P.S. It looks like TDPL will scream today through the 100,000 words 
barrier (at 97,781 words now, see and track at www.erdani.com). When 
that happens, I'll celebrate by making another excerpt available online.
Congrats!
Oct 24 2009
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Max Samukha wrote:
 On Fri, 23 Oct 2009 13:08:06 -0500, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org> wrote:
 
 I wanted to use auto, but ddoc cannot document functions with auto returns.

 Andrei
When I need to hack around an 'auto' bug, I sometimes factor out the return type to a template: template IotaRet(B, E, S = size_t) { alias Take!(Sequence!("a.field[0] + n * a.field[1]", Tuple!(CommonType!(B, E), S))) IotaRet; } IotaRet!(B, E, S) iota(B, E, S)(B begin, E end, S step) {} IotaRet!(B, E) iota(B, E)(B begin, E end) {}
I think I'll do that.
 P.S. It looks like TDPL will scream today through the 100,000 words 
 barrier (at 97,781 words now, see and track at www.erdani.com). When 
 that happens, I'll celebrate by making another excerpt available online.
Congrats!
Well not just yet. I had to remove a wad of text that was dedicated to T[new], so after a full day's work I'm only at 97,917 words. Andrei
Oct 24 2009
prev sibling parent reply grauzone <none example.net> writes:
Andrei Alexandrescu wrote:
 Pelle Månsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota
This link jumps straight to: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) iota(B, E, S)(B begin, E end, S step); Wow, please tell me this is a ddoc malfunction. I mean, that thing left to iota is supposed to be a type? (OK, it _is_ a malfunction, but that thing is still supposed to be... a type?)
Oct 23 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
grauzone wrote:
 Andrei Alexandrescu wrote:
 Pelle MÃ¥nsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota
This link jumps straight to: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) iota(B, E, S)(B begin, E end, S step); Wow, please tell me this is a ddoc malfunction. I mean, that thing left to iota is supposed to be a type? (OK, it _is_ a malfunction, but that thing is still supposed to be... a type?)
Well what was I supposed to do? It was either define another type Iota, or reuse existing types. I chose to reuse. Andrei
Oct 23 2009
parent reply rmcguire <rjmcguire gmail.com> writes:
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:
 
 grauzone wrote:
 Andrei Alexandrescu wrote:
 Pelle Månsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota
This link jumps straight to: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) iota(B, E, S)(B begin, E end, S step); Wow, please tell me this is a ddoc malfunction. I mean, that thing left to iota is supposed to be a type? (OK, it _is_ a malfunction, but that thing is still supposed to be... a type?)
Well what was I supposed to do? It was either define another type Iota, or reuse existing types. I chose to reuse. Andrei
Hi Andrei, Could you tell me why: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) Is a type and not a value? -Rory
Oct 30 2009
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
rmcguire wrote:
 Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:
  
 grauzone wrote:
 Andrei Alexandrescu wrote:
 Pelle Månsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list = list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable syntax. Python has taught me how much useful a readable syntax is :-) Designing languages requires to find a balance between several different and opposed needs. Bye, bearophile
how about this hypothetical syntax: list ~= [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~= array(iota(0, 10)); Andrei
What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota
This link jumps straight to: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) iota(B, E, S)(B begin, E end, S step); Wow, please tell me this is a ddoc malfunction. I mean, that thing left to iota is supposed to be a type? (OK, it _is_ a malfunction, but that thing is still supposed to be... a type?)
Well what was I supposed to do? It was either define another type Iota, or reuse existing types. I chose to reuse. Andrei
Hi Andrei, Could you tell me why: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) Is a type and not a value? -Rory
Take!( Sequence!( "a.field[0] + n * a.field[1]", Tuple!( CommonType!(B,E), S ) ) ) If you look here: http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/algorithm.d and in related files, you'll see that Take is a type with one parameter. Then Sequence is a type with two parameters. Then Tuple is a type with any number of parameters, and so is CommonType. So in spite of it looking complicated, it's just a usual instantiation of a few parameterized types. (What may confuse a C++ programmer is the presence of the string - it's just a template argument.) Andrei
Oct 30 2009
prev sibling parent "Denis Koroskin" <2korden gmail.com> writes:
On Fri, 30 Oct 2009 10:05:27 +0300, rmcguire <rjmcguire gmail.com> wrote=
:

 Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:

 grauzone wrote:
 Andrei Alexandrescu wrote:
 Pelle M=C3=A5nsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list =3D list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable=
 syntax. Python has taught me how much useful a readable syntax =
is =
 :-)
 Designing languages requires to find a balance between several
 different and opposed needs.

 Bye,
 bearophile
how about this hypothetical syntax: list ~=3D [0..10];
I'm not sure what the type of "list" is supposed to be, but this works today for arrays: list ~=3D array(iota(0, 10)); Andrei
What does iota mean?
http://www.digitalmars.com/d/2.0/phobos/std_range.html#iota
This link jumps straight to: Take!(Sequence!("a.field[0] + n * a.field[1]",Tuple!(CommonType!(B,E),S))) iota(B, E, S)(B begin, E en=
d, =
 S
 step);

 Wow, please tell me this is a ddoc malfunction. I mean, that thing l=
eft
 to iota is supposed to be a type?

 (OK, it _is_ a malfunction, but that thing is still supposed to be..=
. a
 type?)
Well what was I supposed to do? It was either define another type Iot=
a,
 or reuse existing types. I chose to reuse.

 Andrei
Hi Andrei, Could you tell me why: Take!(Sequence!("a.field[0] + n * =
 a.field[1]",Tuple!(CommonType!(B,E),S)))

 Is a type and not a value?

 -Rory
I guess Take!(T) is a type, returned by a take(T t, int limit) function = = (it accepts a range and returns other range with a "limit" elements at = most). The naming is consistent with a function, but capitalized to = reflect that it's actually a type, not a function.
Oct 30 2009
prev sibling parent =?ISO-8859-1?Q?=22J=E9r=F4me_M=2E_Berger=22?= <jeberger free.fr> writes:
Pelle M=E5nsson wrote:
 Andrei Alexandrescu wrote:
 Yigal Chripun wrote:
 On 23/10/2009 13:02, bearophile wrote:
 Chris Nicholson-Sauls:

 I prefer this (Scala):
 list =3D list ++ (0 to 10)
That's quite less readable. Scala sometimes has some unreadable=20 syntax. Python has taught me how much useful a readable syntax is :-=
)
 Designing languages requires to find a balance between several=20
 different and opposed needs.

 Bye,
 bearophile
how about this hypothetical syntax: list ~=3D [0..10];
I'm not sure what the type of "list" is supposed to be, but this works=
=20
 today for arrays:

 list ~=3D array(iota(0, 10));


 Andrei
What does iota mean?
In English: "A very small amount". This helped didn't it? ;) The=20 others have already answered for the D meaning. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Oct 23 2009