How to use String in Alloy?

旧街凉风 提交于 2020-01-17 03:55:43

问题


How to use String in Alloy?

What kind of function or operators for String are supported in Alloy?

I searched questions here and find String is a keyword in Alloy. But I cannot find any reference about how to use String in Alloy. Could you give one? If not, is possible to give a brief about String in Alloy?


回答1:


You can actually use strings in Alloy, but only as literals to specify constant values (i.e., no string operations are supported, and Alloy does not implement a string solver). That said, the main use of strings is Alloy is to assign constant string literals to some fields for the sole purpose of making the generated instances more readable when visualized. Here is a simple example

sig Person {
  name: String,
  email: String
}
one sig P1 extends Person {} {
  name = "Joe"
  email = "joe@email.com"
}
run {
  some p: Person | p.name != "Joe"
}


来源:https://stackoverflow.com/questions/26928860/how-to-use-string-in-alloy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!