[nem-bug] [Nemerle 0000797]: problem with caching of properties returning arrays

feedback at nemerle.org feedback at nemerle.org
Wed Nov 29 21:48:31 CET 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=797> 
======================================================================
Reported By:                malekith
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   797
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             11-29-2006 15:20 CET
Last Modified:              11-29-2006 21:48 CET
======================================================================
Summary:                    problem with caching of properties returning arrays
Description: 
class A {
  public Foo : array [int]
  {
    get { System.Console.WriteLine ("Buffer_get called"); array (1) }
  }
}

def a = A ();
a.Foo [0] += 2;

Foo is called twice.
======================================================================

----------------------------------------------------------------------
 nazgul - 11-29-06 21:39 
----------------------------------------------------------------------
The problem is

Foo : array [int] { 
  get { array(1) }
}

vs

Foo [x : int] : int {
  get { 0 }
  set {  }
}

which is not distinguishable on syntax level:

Foo [0] += 1;

but requires different approach:

def tmp = Foo;
tmp [0] = tmp [0] + 1;

for array vs just leaving

Foo [0] = Foo [0] + 1   --->  set_Foo (0, get_Foo (0))

I guess we should just use Cached for whole cached object - this requires
Cached to be handled properly in function/property context:

$cached = Foo [0];
$cached_ref = $cached_ref + 1;

would automatically convert to  set_Foo (0, get_Foo (0)) if we are dealing
with properties.

----------------------------------------------------------------------
 nazgul - 11-29-06 21:48 
----------------------------------------------------------------------
And current caching macro fails on:

class A {
  public Foo[x : int] : int
  {
    get { 1 }
    set { }
  }
  
  public Foo[x : int, y : int] : int {
     get {1 }
     set { }   
  }
  
  public Bar () : void {
    Foo[0] += 1;
  }
}

Issue History
Date Modified  Username       Field                    Change              
======================================================================
11-29-06 15:20 malekith       New Issue                                    
11-29-06 21:39 nazgul         Note Added: 0001536                          
11-29-06 21:48 nazgul         Note Added: 0001537                          
======================================================================




More information about the bugs mailing list