问题解答搬运:什么是DSL,DSL有什么意义

问题起因:
在github的chisel训练营里的第三模块2.1_first_module有一句
Chisel stands for Constructing Hardware In a Scala Embedded Language. That means it is a DSL in Scala, allowing you to take advantage of both Scala and Chisel programming within the same code means it is a DSL in Scala

STACKFLOW里面回答:
在需要将系统控制的某些方面交给其他人的情况下,DSL很有用。(DSL’s are good in situations where you need to give some aspect of the system’s control over to someone else. )

I’ve used them in Rules Engines, where you create a simple language that is easier for less-technical folks to use to express themselves- particularly in workflows.In other words, instead of making them learn java:

DocumentDAO myDocumentDAO = ServiceLocator.getDocumentDAO();
for (int id : documentIDS) {
Document myDoc = MyDocumentDAO.loadDoc(id);
if (myDoc.getDocumentStatus().equals(DocumentStatus.UNREAD)) {
ReminderService.sendUnreadReminder(myDoc)
}
I can write a DSL that lets me say:

for (document : documents) {
if (document is unread) {
document.sendReminder
}

There are other situations, but basically, anywhere you might want to use a macro language(宏语言), script a workflow, or allow after-market customization(售后定制)- these are all candidates for DSL’s.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值