View mode: basic / threaded / horizontal-split · Log in · Help
November 22, 2012
Re: Remus
On 2012-11-22 13:19, John Chapman wrote:

> I believe Jacob is referring to C#'s auto-implemented properties:
> http://msdn.microsoft.com/en-us/library/bb384054.aspx
>
> The compiler generates the get/set pair and backing store from the
> user's single-line declaration.
>
> So,
>
>     @property int bar();
>
> would expand to:
>
>    private int bar_;
>
>    @property void bar(int value) {
>      bar_ = value;
>    }
>
>    @property int bar() {
>      return bar_;
>    }


Yeah, that's what I wrote.

-- 
/Jacob Carlborg
December 03, 2012
Re: Remus
Remus, or now Romulus, is mostly finished.
For two days it is also on github:
https://github.com/Dgame/Romulus/tree/master/Romulus
I expect that at the end of the week a first, small decription 
and "how to use" section will be online. Feel free to comment my 
code.
December 04, 2012
Re: Remus
Last pull today. Romulus is ready to use/test. A website and 
documentation coming soon and then I need some help to write it 
in english. But first I hope that some of you could test it.

Here a brief overview:
 - not null references. Syntax: Object& obj
 - final variables. mutable access, but not rebindable. Syntax: 
final Object obj
 - readonly variables, even called "lazy const". constant 
variable, not rebindable but value must not assign by 
declaration. Syntax: readonly int i;
 - Elvis operator. Short ternary operator.
Syntax:
Object o;
// ...
o = o ?: new Object();

 - Not null safe invocation. Syntax: a?.b?.c will be converted to:
if (a && a.b) a.b.c. (works only with identifiers).

- Scoped arrays. scoped and static/stack array with the ability, 
that their size could be a runtime value. You can resize them, 
but if you do and if the capacity is fully used, it is 
reallocated on the heap. After leaving scope the memory is 
automatically destroyed, even if you have reallocated memory on 
the heap.
Syntax:
scope byte[4] arr1;
int i = 4;
scope byte[i] arr2;
December 04, 2012
Re: Remus
Last pull today. Romulus is ready to use/test. A website and 
documentation coming soon and then I need some help to write it 
in english. But first I hope that some of you could test it.

Here a brief overview:
 - not null references. Syntax: Object& obj
 - final variables. mutable access, but not rebindable. Syntax: 
final Object obj
 - readonly variables, even called "lazy const". constant 
variable, not rebindable but value must not assign by 
declaration. Syntax: readonly int i;
 - Elvis operator. Short ternary operator.
Syntax:
Object o;
// ...
o = o ?: new Object();

 - Not null safe invocation. Syntax: a?.b?.c will be converted to:
if (a && a.b) a.b.c. (works only with identifiers).

- Scoped arrays. scoped and static/stack array with the ability, 
that their size could be a runtime value. You can resize them, 
but if you do and if the capacity is fully used, it is 
reallocated on the heap. After leaving scope the memory is 
automatically destroyed, even if you have reallocated memory on 
the heap.
Syntax:
scope byte[4] arr1;
int i = 4;
scope byte[i] arr2;
December 05, 2012
Re: Remus
On 2012-12-04 22:59, Namespace wrote:
> Last pull today. Romulus is ready to use/test. A website and
> documentation coming soon and then I need some help to write it in
> english. But first I hope that some of you could test it.
>
> Here a brief overview:
>   - not null references. Syntax: Object& obj
>   - final variables. mutable access, but not rebindable. Syntax: final
> Object obj
>   - readonly variables, even called "lazy const". constant variable, not
> rebindable but value must not assign by declaration. Syntax: readonly
> int i;
>   - Elvis operator. Short ternary operator.
> Syntax:
> Object o;
> // ...
> o = o ?: new Object();
>
>   - Not null safe invocation. Syntax: a?.b?.c will be converted to:
> if (a && a.b) a.b.c. (works only with identifiers).
>
> - Scoped arrays. scoped and static/stack array with the ability, that
> their size could be a runtime value. You can resize them, but if you do
> and if the capacity is fully used, it is reallocated on the heap. After
> leaving scope the memory is automatically destroyed, even if you have
> reallocated memory on the heap.
> Syntax:
> scope byte[4] arr1;
> int i = 4;
> scope byte[i] arr2;

Looks good.

-- 
/Jacob Carlborg
December 05, 2012
Re: Remus
On Tuesday, 4 December 2012 at 21:59:15 UTC, Namespace wrote:
[cut]
>  - readonly variables, even called "lazy const". constant 
> variable, not rebindable but value must not assign by 
> declaration. Syntax: readonly int i;

In the (unlikely) case you didn't know: the name for this feature 
in Eiffel is "once" variable.

BR,
renoX
December 05, 2012
Re: Remus
On Wednesday, 5 December 2012 at 13:36:14 UTC, renoX wrote:
> On Tuesday, 4 December 2012 at 21:59:15 UTC, Namespace wrote:
> [cut]
>> - readonly variables, even called "lazy const". constant 
>> variable, not rebindable but value must not assign by 
>> declaration. Syntax: readonly int i;
>
> In the (unlikely) case you didn't know: the name for this 
> feature in Eiffel is "once" variable.
>
> BR,
> renoX

I really did not know that, thanks. I will change the name 
directly. once is a "little" more intuitive than readonly.
December 05, 2012
Re: Remus
On Wednesday, 5 December 2012 at 13:36:14 UTC, renoX wrote:
> On Tuesday, 4 December 2012 at 21:59:15 UTC, Namespace wrote:
> [cut]
>> - readonly variables, even called "lazy const". constant 
>> variable, not rebindable but value must not assign by 
>> declaration. Syntax: readonly int i;
>
> In the (unlikely) case you didn't know: the name for this 
> feature in Eiffel is "once" variable.
>
> BR,
> renoX

Changed. ReadOnly is now Once.
Furthermore I improved the Elvis operator. You can now write:
Foo f;
Foo f2 = f !is null ?: new Foo();
This will be translated to:
Foo f2 = f !is null ? f : new Foo();

Only the valid identifier will be taken.
But take care of this. If you write int[] arr = other_arr.length 
?: [1, 2, 3]; You don't get only 'other_arr', but 
'other_arr.length'. This is because of using member 
functions/propoerties with elvis operators.
December 06, 2012
Re: Remus
> But take care of this. If you write int[] arr = 
> other_arr.length ?: [1, 2, 3]; You don't get only 'other_arr', 
> but 'other_arr.length'. This is because of using member 
> functions/propoerties with elvis operators.

Improved.
Examples:

// declaration of vars...
int[] values = vars[].length == 0 ?: [1, 2, 3];
or
int[] values = vars[].length != 0 ?: [1, 2, 3];
or
int[] values = vars[].length > 0 ?: [1, 2, 3];

will be converted to:
int[] values = vars[].length == 0 ? vars[] : [1, 2, 3];

But if you write:
int[] values = vars[].length ?: [1, 2, 3];

you get:
int[] values = vars[].length == 0 ? vars.length : [1, 2, 3];

So if you have a compare operator after the last .property, only 
the identifiers before that will be taken.
December 28, 2012
Re: Remus
Update:
Now available: auto ref compiler.
Because I assume that the 'auto ref' situation won't be fixed in 
this release, I wrote a workaround which provides remedy. But I 
still hope, that someone writes a solution.

So these code:
https://github.com/Dgame/Romulus/blob/master/Romulus/test/praesi.d
is converted to: 
https://github.com/Dgame/Romulus/blob/master/Romulus/test/Romulus_praesi.d

It isn't perfect because _all_ possible permutation (2^n) are 
generated, but better than nothing.
4 5 6 7 8 9
Top | Discussion index | About this forum | D home