June 24, 2005
"Unknown W. Brackets" <unknown@simplemachines.org> wrote in message news:d9hdfk$30f5$2@digitaldaemon.com...
> Aha!  This is what I got wrong when testing for function existance.
>
> I don't mean to repeat myself, but is this going to find its way into the documentation?  I would argue it's very useful (in fact I did, possibly not-to-successfully.)

It's in the documentation: "The condition is satisfied if Type is semantically correct (it must be syntactically correct regardless)."


June 24, 2005
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:d9gj4d$1vge$1@digitaldaemon.com...
> Walter wrote:
> > "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:d98uen$2tg1$1@digitaldaemon.com...
> <snip>
> >>It would appear to be a bug that this complies - it isn't among the listed forms of IsExpression.
> >
> > It's a feature, not a bug <g>. The feature is that if the type inside
the
> > is( ) parentheses fails to compile *for whatever reason* then the
> > IsExpression result is false.
>
> For whatever reason?  Then
>
>      static if (is(/.,mnbv\][)) { ... }
>
> should compile?

No, as that is not syntactically correct.

> > In this case, o.toHash() is not a type, so it fails to compile, and
> > IsExpression returns false.
>
> You tell us that the IsExpression must be syntactically valid regardless.

Yes. I miswrote the "for whatever reason", as it still must be syntactically valid.


June 24, 2005
Walter wrote:
> "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
> news:d9gj4d$1vge$1@digitaldaemon.com...
<snip>
>>For whatever reason?  Then
>>
>>     static if (is(/.,mnbv\][)) { ... }
>>
>>should compile?
> 
> No, as that is not syntactically correct.
<snip>

Exactly.  Neither is the OP's snippet according to the forms of IsExpression allowed by the spec.

Or is

    o.toHash()

parseable as a type by some obscure feature none of us have discovered?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
June 24, 2005
In article <d9hb8g$2ucm$1@digitaldaemon.com>, Sean Kelly says...
>
>In article <1f1np8srt6jk1.j36513qm0sd7.dlg@40tude.net>, Derek Parnell says...
>>But that is exactly what I'd like to prevent! In other words I'd like to do this sort of thing ...
>>
>>  static_if (! exists(S.m))
>>  {
>>      // declare 'm'
>>  }
>
>I like the new features, but using "is" in this way (since it's also a non-static binary operator) is somewhat confusing.  In some respects I'd prefer a new keyowrd for this purpose--istype perhaps?

I agree.  D should probably use something like istype(), exists(),  or just
anything_other_than_is().  Overloading 'is' like this is a tad confusing to the
eye.  At first glance, it just doesn't look like valid D code (IMO).

- EricAnderton at yahoo
June 24, 2005
In article <d9hgh1$2j4$1@digitaldaemon.com>, Stewart Gordon says...
>
>Or is
>
>     o.toHash()
>
>parseable as a type by some obscure feature none of us have discovered?

I was wondering about this as well.


Sean


June 24, 2005
Well, then, forgive me for being daft but upon reading that twice I still did not consider that it could be used to check for the existance of functions, types, and methods which do not currently exist.

I now understand that, but it seems like a more useful feature than just one sentence.  Maybe the documentation could at least describe that this:

int main()
{
   static if (is(typeof(someTypeOrFunctionThatDoesNotExist)))
      writef("This will never be output.");

   static if (is(typeof(Object.someMethodOrMemberThatDoesNotExist)))
      writef("This will never be output either.");
}

Will compile (and run) fine.  You could probably give a better example, though.

I just mean that the word "type" is used quite a number of times in the IsExpression documentation, and it is not immediately logical that this means that a typeof expression can be used with a value that does not exist.

Now that I understand this, the various forms of is() make much more sense, in fact this looks interesting:

    static if (is(typeof(myfunc) T))
        T* myfunc_fp = &myfunc;

-[Unknown]


> "Unknown W. Brackets" <unknown@simplemachines.org> wrote in message
> news:d9hdfk$30f5$2@digitaldaemon.com...
> 
>>Aha!  This is what I got wrong when testing for function existance.
>>
>>I don't mean to repeat myself, but is this going to find its way into
>>the documentation?  I would argue it's very useful (in fact I did,
>>possibly not-to-successfully.)
> 
> 
> It's in the documentation: "The condition is satisfied if Type is
> semantically correct (it must be syntactically correct regardless)."
> 
> 
June 25, 2005
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:d9hgh1$2j4$1@digitaldaemon.com...
> Walter wrote:
> > "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:d9gj4d$1vge$1@digitaldaemon.com...
> <snip>
> >>For whatever reason?  Then
> >>
> >>     static if (is(/.,mnbv\][)) { ... }
> >>
> >>should compile?
> >
> > No, as that is not syntactically correct.
> <snip>
>
> Exactly.  Neither is the OP's snippet according to the forms of IsExpression allowed by the spec.
>
> Or is
>
>      o.toHash()
>
> parseable as a type by some obscure feature none of us have discovered?

No, it isn't parseable as a type.


July 11, 2005
Walter wrote:
> "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
> news:d9hgh1$2j4$1@digitaldaemon.com...
<snip>
>> Or is
>>
>>      o.toHash()
>>
>> parseable as a type by some obscure feature none of us have discovered?
> 
> No, it isn't parseable as a type.

Exactly.  Therefore

    is(o.toHash())

isn't a syntactically valid IsExpression.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- a->--- UB@ P+ L E@ W++@ N+++ o K- w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
1 2
Next ›   Last »