I have a question.
-- sample.n
public class Foo {
mutable _bar : string;
public Bar : string {
get { _bar }
set { _bar = value; }
}
}
--
-- sample.cs
public class Foo {
string _bar;
public string Bar {
get { return _bar; }
set { _bar = value; }
}
}
--
sample.n and sample.cs are same?
compiled sample.n and disassemble it.
result of Bar property is
.property string Bar(string)
{
.get instance string Foo::get_Bar()
.set instance void Foo::set_Bar(string)
} // end of property Foo::Bar
but sample.cs is
.property instance string Bar()
{
.get instance string Foo::get_Bar()
.set instance void Foo::set_Bar(string)
} // end of property Foo::Bar
Bar parameter is different.
Why?
Kamil Skalski wrote:
When I compile and dissasemble this program I get:
.class public auto ansi Foo
extends [mscorlib]System.Object
{
.field private string _bar
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 2
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Foo::.ctor
.method public hidebysig specialname instance string
get_Bar() cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ldfld string Foo::_bar
IL_0006: ret
} // end of method Foo::get_Bar
.method public hidebysig specialname instance void
set_Bar(string 'value') cil managed
{
// Code size 8 (0x8)
.maxstack 2
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string Foo::_bar
IL_0007: ret
} // end of method Foo::set_Bar
.property string Bar(string)
{
.get instance string Foo::get_Bar()
.set instance void Foo::set_Bar(string)
} // end of property Foo::Bar
} // end of class Foo
I'm not sure how did you get the code you mentioned, but it must be
some mistake...
2006/5/27, mei <mei@xxxxxxxxxxxxxxxx>:
Hi,
I want to know about accessor macro.
-- sample.n
using System;
using System.IO;
using Nemerle.Utility;
public class Foo {
[Accessor(flags=WantSetter)] mutable _bar : string;
}
--
compiled sample.n to dll(assembly) and use from C#.
but error CS1545 occurred.
then, I disassemble the compiled asseimbly by Reflector.
--
public class Foo
{
// Methods
public Foo();
// Properties
public string this[string] { get; set; }
// Fields
private string _bar;
}
--
there is indexer, but Bar property is not exists.
Please give me instructions for using the accessor macro.
Thanks.
--
akiramei <mei@xxxxxxxxxxxxxxxx>
_______________________________________________
https://nemerle.org/mailman/listinfo/devel-en
--
mei <mei@xxxxxxxxxxxxxxxx>
|