Re: Cushion the state transition table library released

2019-06-29 Thread ag0aep6g via Digitalmars-d-announce

On 28.06.19 16:18, Atila Neves wrote:
Would you consider writing a blog post about it? I'm sure it would be 
helpful to a lot of people.


I wrote a little something up:

https://gist.github.com/aG0aep6G/f267e316d1dce2763252d82c1808d53a

I'm not sure if it's all that helpful, but I don't think I'm willing to 
invest considerably more time into improving it further.


Re: Cushion the state transition table library released

2019-06-28 Thread Guillaume Piolat via Digitalmars-d-announce

On Thursday, 27 June 2019 at 22:36:14 UTC, ag0aep6g wrote:

On 27.06.19 23:34, aliak wrote:
I really love that you go in to the code and find things like 
this, especially when it comes to abuse of @trusted, but maybe 
a little explanation as to why would be more helpful to the OP 
;)


Probably. But this isn't D.learn, and I'm getting tired of 
explaining @trusted.


I don't want to discourage anyone from writing libraries and 
showing them off here, but I do want to discourage people from 
writing @trusted code.


If you've identified guidelines for using @trusted it could be 
really useful to put it in some text form. :)


Re: Cushion the state transition table library released

2019-06-28 Thread Atila Neves via Digitalmars-d-announce

On Thursday, 27 June 2019 at 22:36:14 UTC, ag0aep6g wrote:

On 27.06.19 23:34, aliak wrote:
I really love that you go in to the code and find things like 
this, especially when it comes to abuse of @trusted, but maybe 
a little explanation as to why would be more helpful to the OP 
;)


Probably. But this isn't D.learn, and I'm getting tired of 
explaining @trusted.


Would you consider writing a blog post about it? I'm sure it 
would be helpful to a lot of people.






Re: Cushion the state transition table library released

2019-06-27 Thread ag0aep6g via Digitalmars-d-announce

On 27.06.19 23:34, aliak wrote:
I really love that you go in to the code and find things like this, 
especially when it comes to abuse of @trusted, but maybe a little 
explanation as to why would be more helpful to the OP ;)


Probably. But this isn't D.learn, and I'm getting tired of explaining 
@trusted.


I don't want to discourage anyone from writing libraries and showing 
them off here, but I do want to discourage people from writing @trusted 
code.


Re: Cushion the state transition table library released

2019-06-27 Thread aliak via Digitalmars-d-announce

On Wednesday, 26 June 2019 at 15:20:45 UTC, ag0aep6g wrote:

On 26.06.19 16:01, SHOO wrote:

[...]


You've got bad `@trusted`s.

Quoting from there:

[...]


No.


[...]

[...]

[...]


Noo.


[...]

[...]

[...]

[...]

[...]

[...]

[...]


Nooo.


[...]

[...]

[...]

[...]

[...]

[...]

[...]


N.


[...]

[...]

[...]

[...]>   EventContainer   _events;
[...]

[...]

[...]

[...]

[...]

[...]

[...]

[...]


No.


I really love that you go in to the code and find things like 
this, especially when it comes to abuse of @trusted, but maybe a 
little explanation as to why would be more helpful to the OP ;)


Re: Cushion the state transition table library released

2019-06-27 Thread Digital Mars via Digitalmars-d-announce

27.06.2019 13:52, SHOO пишет:

Thank you for your technical review.
You can report new issues on GitHub: https://github.com/shoo/cushion/issues
Or, you may also create a pull request: 
https://github.com/shoo/cushion/pulls


IMHO, this is unusual for D community to make review in such form. I 
hope it won't repeat. Thank you for your patience.


Re: Cushion the state transition table library released

2019-06-27 Thread SHOO via Digitalmars-d-announce

On Wednesday, 26 June 2019 at 15:20:45 UTC, ag0aep6g wrote:

On 26.06.19 16:01, SHOO wrote:

GitHub: https://github.com/shoo/cushion


You've got bad `@trusted`s.

Quoting from there:

pragma(inline) T trustedCast(T, Arg)(Arg arg) @trusted
{
return cast(T)arg;
}

[...]

No.


Thank you for your technical review.
You can report new issues on GitHub: 
https://github.com/shoo/cushion/issues
Or, you may also create a pull request: 
https://github.com/shoo/cushion/pulls


Cushion the state transition table library released

2019-06-26 Thread SHOO via Digitalmars-d-announce
Cushion is a library for managing state transition by state 
transition table design.
This library parses CSV format tabular file described the design 
of states passed by string import and generates D language code. 
It can be used with string mixin.


It may be useful if you are dealing with a program that changes 
behavior depending on the state.


Thanks!

DUB: https://code.dlang.org/packages/cushion
GitHub: https://github.com/shoo/cushion



Re: Cushion the state transition table library released

2019-06-26 Thread ag0aep6g via Digitalmars-d-announce

On 26.06.19 16:01, SHOO wrote:

GitHub: https://github.com/shoo/cushion


You've got bad `@trusted`s.

Quoting from there:

pragma(inline) T trustedCast(T, Arg)(Arg arg) @trusted
{
return cast(T)arg;
}


No.


pragma(inline) void call(Handler, Args...)(ref Handler handler, Args args) 
@trusted
{

[...]

handler(args);


Noo.


pragma(inline) void add(Handler, Func)(ref Handler handler, Func func) @trusted
{

[...]

handler ~= func;

[...]

handler.insert(func);

[...]

handler.connect(func);


Nooo.


pragma(inline) void remove(Handler, Func)(ref Handler handler, Func func) 
@trusted
{

[...]

__traits(getMember, handler, "remove")(func);

[...]

handler.disconnect(func);

[...]

handler.linearRemoveElement(func);


N.


struct StateTransitor(

[...]

EventContainer = SList!EventType)
{

[...]>   EventContainer   _events;
[...]

void consume() @safe
{

[...]

() @trusted
{

[...]

_events.removeFront();

[...]

}();
}


No.