Alloy 4 Int scope - alloy

Last year I used alloy and I could set the scope of the Int bitwidth writing, for example,
"5 Int"
as is indeed suggested by the following answer:
run command scope in alloy
However, I have downloaded Alloy 4.1.1 this year again and if I wrote
sig Bar{ a:Int}
run{} for 10 Int
I now obtain
Syntax error at line 3 column 11:
You can no longer set a scope on Int; the number of Int
atoms is always exactly equal to 2^(integer bitwidth).
What is changed? How should I set the bitwidth?

In Alloy 4.1.1 just change Int to int, and that will work. In Alloy 4.2 you can use either one, because in 4.2 they are both used to specify the bitwidth.

Related

VS Code Python 3- Hover over variable types

Python in VS Code
When I hover over some variables I get this showing. How do I make sense of this? Does it mean that the value variable has an int and a float type? Unfortunately I don't have the reputation to display the image directly on the post.
It means the variable can be either int or float type depends on the runtime environment.

Does PyIntObject still in python3.x source code?

Does PyIntObject still in python3.x source code,or has it been replaced by PyLongObject? I can't find the code as follows:
typedef struct {
PyObject_HEAD
long ob_ival;
} PyIntObject;
From https://docs.python.org/3.2/howto/cporting.html (long/int Unification):
Python 3 has only one integer type, int(). But it actually corresponds to Python 2’s long() type–the int() type used in Python 2 was removed. In the C-API, PyInt_* functions are replaced by their PyLong_* equivalents.
The best course of action here is using the PyInt_* functions aliased to PyLong_* found in intobject.h. The abstract PyNumber_* APIs can also be used in some cases.
Please check also the following discussion:
How does Python manage int and long?

Xtext terminal rule for float

I have tried to define a float type in Xtext however I receive a error message when generate aritifact :
The following token definitions can never be matched because prior tokens match the same input:RULE_FLOAT,RULE_INT
My terminal for float is as follows:
terminal FLOAT returns ecore::EFloat: INT '.' INT;
My float is to replicate a float that is able to be accepted by Java:
1.1 ,
1 ,
0.1
Terminal rules are order dependent. The first match usually wins. Your grammar seems to contain another rule that already matches INT.INT but that's impossible to tell from the information that you provide. Generally speaking it's a good idea to use data type rules to describe the syntax of floats.
That would read (note the missing terminal keyword):
Float returns ecore::EFloat: INT '.' INT;

Why a variable can't start with a number but can ends with it? [duplicate]

This question already has answers here:
Why can't variable names start with numbers?
(24 answers)
Closed 8 years ago.
In many languages (C#, Javascript, CSS, and so on) I can't declare this variable:
123test
but I can declare this:
test123
What's the real cause of it?
It simplifies the parser. It can tell from the first character in a token whether it's an identifier or a number.
Also, the syntax for floating point can look like this:
123e45
This means 123x1045. If identifiers could start with a number, this could be confused with a variable.
There are some languages that don't have this prohibition, Common Lisp for instance. It's rule is essentially that the token is a symbol unless it can be parsed as a number. Since it also allows the input radix to be customized, it has the property that whether a token is a number or symbol depends on the setting of a variable (it also has escaping mechanisms that allow you to force it one way or the other).
Because then a string of digits would be a valid identifier as well as a valid number.
int 17 = 497;
int 42 = 6 * 9;
String 1111 = "Totally text";
#skiphoppy`s answear.
More information: Why can't variable names start with numbers?

Can I use $urandom_range with time variables?

I wanted to know if I can simply write:
time time_var;
time_var = $urandom_range (10ms, 7ms);
I've tried using it directly, and there are no errors/warnings issued.
However, the returned value is not between 7-10ms.
I guess it's legal to use $urandom_range with time literals, since I didn't receive any errors. But, why can't I get a value in the proper range?
The IEEE Std (1800-2009) declares the arguments to $urandom_range to be of type int unsigned which is not the same as time. I don't think you can rely on the system function to behave predictably even if you are not getting errors or warnings from your simulator.
It is a compile error in VCS and a warning with Incisive.
Can you use something like this?
int unsigned del = $urandom_range(10, 7);
#(1ms * del);

Resources