向C ++语言添加statemachine支持的建议

编程入门 行业动态 更新时间:2024-10-11 19:20:37
本文介绍了向C ++语言添加statemachine支持的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

最近,作为我工作的一部分,我一直在学习IBM Rhapsody,并使用它从UML生成C ++代码。

Lately as part of my day job I've been learning IBM Rhapsody and using it to generate code in C++ from the UML.

昨天,可能很酷,想想添加状态机支持我的C ++编译器,所以我在这里记下了几点注意: ellcc/wiki/index.php/State_machines_and_Active_Classes

Yesterday it struck me that it might be cool to think about adding state machine support to my C++ compiler, so I jotted a few notes here: ellcc/wiki/index.php/State_machines_and_Active_Classes

我的动机是:

  • 这似乎是一个很酷的想法。
  • 编译器可以做更好的语义检查/正常C ++编译器。
  • 当编译器本身理解状态机结构时,有许多优化可能性。
  • 我可以尝试将我的语法扩展到除了看看它的工作原理的建议。

    I may try to extend my grammar to except something like the proposal to see how well it works.

    您对建议的看法是什么?它看起来可读吗?它似乎值得吗?


    编辑:

    What is your opinion of the proposal? Does it seem readable? Does it seem worthwhile?

    感谢您的建议的特定库做状态机,但这不是我的问题。我已经使用我写的库和代码实现了很多状态机。

    Thanks for the answers recommending specific libraries to do state machines, but that wasn't my question. I've implemented many state machines using both libraries and code that I've written.

    我真的在寻找关于状态设计的想法,批评等机器扩展为C ++语言,而不是这种改变是否适合添加到标准C ++。

    I was really looking for ideas, criticism, etc. about the design of a state machine extension to a C++-like language, not whether this change would be appropriate for addition to standard C++. Think of it as a domain specific extension, where my my domain is real-time control applications.

    我已经开始在我的编译器中实现这个扩展,如下所示: ellcc/wiki/index.php/状态%5Fmachines%5Fand%5FActive%5Flasses

    I've started implementation of the extension in my compiler as described here: ellcc/wiki/index.php/State%5Fmachines%5Fand%5FActive%5FClasses

    到目前为止,这个概念没有必要改变从提案到实现,但已经有一些更改细节,我正在提炼我对问题的语义的理解。

    So far the concept hasn't had to change much going from proposal to implementation but there have been a few changes in details and I'm refining my understanding of the semantics of the problem.

    但是,时间会告诉整个概念是否有任何值。 ; - )

    Time will tell whether the whole concept has any value, however. ;-)

    推荐答案

    除了一些例外,C ++传统上使用类库扩展,而不是新的关键字。状态机可以使用这样的库轻松实现,所以我不认为你的提案有很多机会。

    With a few exceptions, C++ has traditionally been extended using class libraries, not new keywords. State machines can easily be implemented using such libraries, so I don't think your proposal has much of a chance.

    我在提案中看到的一个问题是使用'goto'去另一个状态。如果我想在状态转换中的自己的代码中使用goto,会发生什么?

    One problem I see in your proposal is the use of 'goto' to go to another state. What happens if I want to use goto in my own code within a state transition?

    更多推荐

    向C ++语言添加statemachine支持的建议

    本文发布于:2023-11-06 03:48:41,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1562647.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:语言   建议   statemachine

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!