Re: "Symbol undefined" on interface with public getter and package setter

2009-02-20 Thread Daniel Keep


TSalm wrote:
>>
>> I'm not sure but I think package is not virtual.
> 
> :-(
> So there's really no way to have a method declared "package" in an
> interface ?

You also can't have a private function in an interface.  This once lost
me four days trying to figure out why my program wouldn't link despite
the function very obviously being there.

Stick to public functions only.

  -- Daniel


Re: Making pure functions get dirty (D 2.0)

2009-02-20 Thread Burton Radons
Oh I see what's going on. pure functions get funky processing; if you don't 
actually use their return values they're not even compiled. Once you actually 
take the return value it'll complain about it whether it's a pure inner 
function in a pure outer function or anything else unless if it's a pure outer 
function which is perhaps the most useless thing you could have in this context.


Making pure functions get dirty (D 2.0)

2009-02-20 Thread Burton Radons
I'm writing a general conversion template function a la:

  pure T convert (T, U) (const (U) value);

Sweet, and really handy for template errors because you can tell the user which 
number input it is that angered it. The problem is that if you're converting 
int to string there's allocations there that doesn't have to be there for many 
purposes (also I'm using it for error formatting, which isn't so good if what 
I'm telling the user is that there's no memory for allocations). So I thought 
I'd make it work like this:
 
  // May call write multiple times for arrays, each time builds onto the array.
  void convertInto (T, U, alias write) (const (T) value)
  {
write ("You've bespoiled my honour, cur!\n");
  }

  void convertWith (T, U) (const (U) value, void delegate (T) write)
  {
convertInto! (T, U, write) (value);
  }

  import std.stdio;
  void main ()
  {
void write (string text) { writef (text); }
convertWith! (string, string) ("Let's you and I spend a few moments alone 
without a chaperone, baby.\n", &write);
  }

Strangely enough this compiles but it doesn't actually DO anything (everything 
works, it's just that convertInto is not called at all); just taking the pure 
off fixes it. Obviously it shouldn't work, but what would I do to make an 
conditionally-pure function like this without code replication or mixin madness?

It feels like I'm missing some kind of "third way".


Re: Making pure functions get dirty (D 2.0)

2009-02-20 Thread Burton Radons
Burton Radons Wrote:

>   void convertInto (T, U, alias write) (const (T) value)

This should read "pure void". Everything I said about its behaviour is correct 
for my experiences.


Re: "Symbol undefined" on interface with public getter and package setter

2009-02-20 Thread TSalm


I'm not sure but I think package is not virtual.


:-(
So there's really no way to have a method declared "package" in an  
interface ?




Re: "Symbol undefined" on interface with public getter and package setter

2009-02-20 Thread Jacob Carlborg

TSalm wrote:

Hello,

When I compile the code below, I've got the following error :
 OPTLINK (R) for Win32  Release 8.00.1
 Copyright (C) Digital Mars 1989-2004  All rights reserved.
 private_method_in_interface_file3.obj(private_method_in_interface_file3)
  Error 42: Symbol Undefined 
_D33private_method_in_interface_file31I4funcMFiZv

 --- errorlevel 1


/* - CODE -- */
interface I
{
   int func() ;
   package void func(int);
}

class A:I
{
  int i;

  package  void func(int i)
  { this.i = i; }

  int func()
  { return i; }
}

void main()
{

  I a = new A ;
  a.func = 10 ;
  Stdout(a.func).newline ;

}
/* --- END CODE  */


Thanks in advance for your help,
TSalm


I'm not sure but I think package is not virtual.


Re: "Symbol undefined" on interface with public getter and package setter

2009-02-20 Thread Jarrett Billingsley
On Fri, Feb 20, 2009 at 3:56 PM, Jacob Carlborg  wrote:
>
> I'm not sure but I think package is not virtual.
>

The compiler should catch that then.


Re: "Symbol undefined" on interface with public getter and package setter

2009-02-20 Thread TSalm

It seems this comes only from the "package" method.

The error is the same with this code :
/* --- CODE --- */
interface I
{
   package void setFunc(int);
}


class A:I
{
  int i;

  package  void setFunc(int i)
  { this.i = i ; }

}


void main()
{

  I a = new A;
  a.setFunc = 10;

}
/* --- END CODE --- */


Hello,

When I compile the code below, I've got the following error :
  OPTLINK (R) for Win32  Release 8.00.1
  Copyright (C) Digital Mars 1989-2004  All rights reserved.
  private_method_in_interface_file3.obj(private_method_in_interface_file3)
   Error 42: Symbol Undefined  
_D33private_method_in_interface_file31I4funcMFiZv

  --- errorlevel 1


/* - CODE -- */
interface I
{
int func() ;
package void func(int);
}

class A:I
{
   int i;

   package  void func(int i)
   { this.i = i; }

   int func()
   { return i; }
}

void main()
{

   I a = new A ;
   a.func = 10 ;
   Stdout(a.func).newline ;

}
/* --- END CODE  */


Thanks in advance for your help,
TSalm




"Symbol undefined" on interface with public getter and package setter

2009-02-20 Thread TSalm

Hello,

When I compile the code below, I've got the following error :
 OPTLINK (R) for Win32  Release 8.00.1
 Copyright (C) Digital Mars 1989-2004  All rights reserved.
 private_method_in_interface_file3.obj(private_method_in_interface_file3)
  Error 42: Symbol Undefined  
_D33private_method_in_interface_file31I4funcMFiZv

 --- errorlevel 1


/* - CODE -- */
interface I
{
   int func() ;
   package void func(int);
}

class A:I
{
  int i;

  package  void func(int i)
  { this.i = i; }

  int func()
  { return i; }
}

void main()
{

  I a = new A ;
  a.func = 10 ;
  Stdout(a.func).newline ;

}
/* --- END CODE  */


Thanks in advance for your help,
TSalm