On 09/07/2010 12:44 AM, bearophile wrote:
Andrej Mitrovic:
I'm sorry, but what does q{..} mean?
q{} is just a different syntax to write "" or ``
It's a controversial feature. q{} isn't recognized by editors as a string, so
they colour the syntax it contains normally as code, and not as a st
I meant string literals. But comments as well.
Andrej Mitrovic Wrote:
> Heh. I'd rather want text editors to use syntax highlighting on comments as
> well, but use a different background color. Then I would know it's a comment
> but it would also make any embedded code in the comment actually r
Heh. I'd rather want text editors to use syntax highlighting on comments as
well, but use a different background color. Then I would know it's a comment
but it would also make any embedded code in the comment actually readable.
bearophile < bearophileh...@lycos.com> Wrote:
> Andrej Mitrovic:
>
Andrej Mitrovic:
> I'm sorry, but what does q{..} mean?
q{} is just a different syntax to write "" or ``
It's a controversial feature. q{} isn't recognized by editors as a string, so
they colour the syntax it contains normally as code, and not as a string. So
it's a bit useful if you want to g
I'm sorry, but what does q{..} mean?
Philippe Sigaud Wrote:
> On Mon, Sep 6, 2010 at 23:31, Andrej Mitrovic
> wrote:
>
> > That still won't work. Observe:
>
>
>
> > template isInputRange(R)
> > {
> > enum bool isInputRange = isValidCode!(
> > {
> >R r;// can d
Andrej Mitrovic:
> enum a = "test";
> a = "test2";
>
> Because it seems to compile. But that shouldn't work afaik..?
I have two open bug reports on this (and a third one was open by Don).
Bye,
bearophile
On Mon, Sep 6, 2010 at 23:31, Andrej Mitrovic wrote:
> That still won't work. Observe:
> template isInputRange(R)
> {
> enum bool isInputRange = isValidCode!(
> {
>R r;// can define a range object
>if (r.empty) {} // can test for empty
>r.popF
Andrej Mitrovic wrote:
That still won't work. Observe:
Oops, sorry, I was too quick to conclude.
Andrej Mitrovic wrote:
is(typeof( is used a lot in Phobos. There's some ~260 calls like that, a quick
search revealed. :p
Hush! You're spoiling it! It's a part of intergalactic obfuscation plot ;p
That still won't work. Observe:
import std.stdio : writeln;
void main()
{
writeln(isInputRange!(N));
}
class N
{
N test;
//~ bool empty() // oops, we"re not an input range anymore
//~ {
//~ return false;
//~ }
@property
void popFront()
{
}
@p
is(typeof( is used a lot in Phobos. There's some ~260 calls like that, a quick
search revealed. :p
Stanislav Blinov Wrote:
> If I remember correctly, it has been discussed not long ago that those
> is(typeof(...))s should really be __traits(compiles). Maybe it's just
> some code was written be
Andrej Mitrovic wrote:
It does look nice. It would look even nicer if __traits gets renamed to meta.
By the way, there's no stopping writing
template isValidCode(alias code) { enum bool isValidCode =
__traits(compiles, code); }
:)
Andrej Mitrovic wrote:
I'd love to see this used more in Phobos. I don't know if there are any
drawbacks, but this looks and works nicely:
import std.stdio : writeln;
void main()
{
writeln(isInputRange!(N));
}
class N
{
N test;
bool empty()
{
return false;
}
Is this legal?:
enum a = "test";
a = "test2";
Because it seems to compile. But that shouldn't work afaik..?
I can't reassign other enum types:
enum b = 4;
b = 5; // error
which is expected.
Pelle Wrote:
> On 09/06/2010 08:53 PM, Philippe Sigaud wrote:
> > On Mon, Sep 6, 2010 at 18:47, Pelle
On 09/06/2010 08:53 PM, Philippe Sigaud wrote:
On Mon, Sep 6, 2010 at 18:47, Pelle mailto:pelle.mans...@gmail.com>> wrote:
On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
Is there a way you could write an isStatic(expr) template? Using
template isStatic( alias T ) {
I'd love to see this used more in Phobos. I don't know if there are any
drawbacks, but this looks and works nicely:
import std.stdio : writeln;
void main()
{
writeln(isInputRange!(N));
}
class N
{
N test;
bool empty()
{
return false;
}
@property
voi
Yeah, that could work:
template isInputRange(R)
{
enum bool isInputRange = __traits(compiles,
{
R r; // can define a range object
if (r.empty) {} // can test for empty
r.popFront; // can invoke next
auto h = r.front; // can get the front of t
Am 06.09.2010 21:24, schrieb Andrej Mitrovic:
Apparently I can't post to D.learn from gmail without waiting for a review?
What the..?
Anyway, I've posted this:
On a related note, I always wanted to make a template to replace the
dreaded is(typeof('delegate literal'())); calls.
For example, in
Andrej Mitrovic wrote:
Apparently I can't post to D.learn from gmail without waiting for a review?
What the..?
Anyway, I've posted this:
On a related note, I always wanted to make a template to replace the
dreaded is(typeof('delegate literal'())); calls.
For example, instead of this:
enum bo
Apparently I can't post to D.learn from gmail without waiting for a review?
What the..?
Anyway, I've posted this:
On a related note, I always wanted to make a template to replace the
dreaded is(typeof('delegate literal'())); calls.
For example, instead of this:
enum bool isInputRange = is(type
On Mon, Sep 6, 2010 at 18:47, Pelle wrote:
> On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
>
>> Is there a way you could write an isStatic(expr) template? Using
>>>
>>
>> template isStatic( alias T ) {
>> enum isStatic = is( char[1+T] );
>> }
>>
>> unittest {
>> int n = 3;
>> assert( !isStatic!n
On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
Peter Alexander wrote:
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
wrote:
> What does char[1 + Range.empty] do? It looks rather cryptic..
char[1+Range.empty] is a type. If
Peter Alexander wrote:
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
wrote:
> What does char[1 + Range.empty] do? It looks rather cryptic..
char[1+Range.empty] is a type. If Range.empty is a compile-time
constant,
th
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
> On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
> wrote:
> > What does char[1 + Range.empty] do? It looks rather cryptic..
> char[1+Range.empty] is a type. If Range.empty is a compile-time constant,
> then this type is valid
Ah, you're right. Whenever I see the square brackets my brain automatically
things "we're indexing something". I'll blame that on C. :p
Thanks.
Steven Schveighoffer Wrote:
> On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
> wrote:
>
> > I was reading about the various range templates in
On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
wrote:
I was reading about the various range templates in std.range and I found
this:
http://www.digitalmars.com/d/2.0/phobos/std_range.html#isInfinite
Seems simple enough. But I dont understand it's implementation, this
from range.d:
I was reading about the various range templates in std.range and I found this:
http://www.digitalmars.com/d/2.0/phobos/std_range.html#isInfinite
Seems simple enough. But I dont understand it's implementation, this from
range.d:
template isInfinite(Range)
{
static if (isInputRange!Range && i
27 matches
Mail list logo