www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - what is missing here?

reply Jonathan Villa <jv_vortex msn.com> writes:
public final class accounts
{
     public:
         static table_user user;
}

public final class table_user
{
     private:
         static uint32 dummy1;
         static string dummy2;
         static DateTime dummy3;
         static ubyte dummy4;
     public:
         static  property auto user_id_t() { return 
typeof(dummy1); }
         static  property auto name_t() { return typeof(dummy2); }
         static  property auto alias_t() { return typeof(dummy2);}
         static  property auto pers_email_t() { return 
typeof(dummy2); }
         static  property auto corp_email_t() { return 
typeof(dummy2); }
         static  property auto password_t() { return 
typeof(dummy2); }
         static  property auto last_login_t() { return 
typeof(dummy3); }
         static  property auto active_t() { return typeof(dummy4); 
}
         static  property auto id_lang_t() { return 
typeof(dummy4); }
         static  property auto function_t() { return 
typeof(dummy4); }
         static  property auto register_date_t() { return 
typeof(dummy3); }
}

for every property it throws me an error at compile time: type 
($) has no value.
I'm trying to do a wrap of a database so when getting a resultset 
using mysql-native I can do
result.front()[0].get!(accounts.user.user_it_t);
si it's more readable.
May 03 2016
parent reply ag0aep6g <anonymous example.com> writes:
On 03.05.2016 18:03, Jonathan Villa wrote:
 public final class accounts
 {
      public:
          static table_user user;
 }

 public final class table_user
 {
      private:
          static uint32 dummy1;
          static string dummy2;
          static DateTime dummy3;
          static ubyte dummy4;
      public:
          static  property auto user_id_t() { return typeof(dummy1); }
          static  property auto name_t() { return typeof(dummy2); }
          static  property auto alias_t() { return typeof(dummy2);}
          static  property auto pers_email_t() { return typeof(dummy2); }
          static  property auto corp_email_t() { return typeof(dummy2); }
          static  property auto password_t() { return typeof(dummy2); }
          static  property auto last_login_t() { return typeof(dummy3); }
          static  property auto active_t() { return typeof(dummy4); }
          static  property auto id_lang_t() { return typeof(dummy4); }
          static  property auto function_t() { return typeof(dummy4); }
          static  property auto register_date_t() { return typeof(dummy3); }
 }

 for every property it throws me an error at compile time: type ($) has
 no value.
 I'm trying to do a wrap of a database so when getting a resultset using
 mysql-native I can do
 result.front()[0].get!(accounts.user.user_it_t);
 si it's more readable.
Types are not values. You cannot return a type from a function. Use aliases instead: ---- alias user_id_t = typeof(dummy1); alias name_t = typeof(dummy2); /* ... etc ... */ ----
May 03 2016
parent Jonathan Villa <jv_vortex msn.com> writes:
On Tuesday, 3 May 2016 at 16:13:07 UTC, ag0aep6g wrote:
 On 03.05.2016 18:03, Jonathan Villa wrote:

 Types are not values. You cannot return a type from a function. 
 Use aliases instead:
 ----
         alias user_id_t = typeof(dummy1);
         alias name_t = typeof(dummy2);
         /* ... etc ... */
 ----
Thank you, I thought alias was just allowed to be declared outside, but declaring them inside as public it now behaves like I want.
May 03 2016