Skip to content

Commit fb78508

Browse files
Rename types (closes #237)
1 parent 5da9002 commit fb78508

139 files changed

Lines changed: 3672 additions & 3621 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ Prefix is a programming language focused on explicit, readable code.
99
! predicts the next value.
1010
1111
! ---------- modular inverse via the extended Euclidean algorithm ----------
12-
FUNC INT modinv(INT a, INT m){
12+
func int modinv(int a, int m){
1313
a = MOD(a, m)
1414
IF(LT(a, 0d0)){ a = +(a, m) }
15-
INT r0 = m
16-
INT r1 = a
17-
INT t0 = 0d0
18-
INT t1 = 0d1
15+
int r0 = m
16+
int r1 = a
17+
int t0 = 0d0
18+
int t1 = 0d1
1919
WHILE(NEQ(r1, 0d0)){
20-
INT q = /(r0, r1)
21-
INT nr = -(r0, *(q, r1))
22-
INT nt = -(t0, *(q, t1))
20+
int q = /(r0, r1)
21+
int nr = -(r0, *(q, r1))
22+
int nt = -(t0, *(q, t1))
2323
r0 = r1
2424
r1 = nr
2525
t0 = t1
@@ -28,27 +28,27 @@ FUNC INT modinv(INT a, INT m){
2828
IF(NEQ(r0, 0d1)){
2929
THROW("modinv: arguments not coprime")
3030
}
31-
INT inv = MOD(t0, m)
31+
int inv = MOD(t0, m)
3232
IF(LT(inv, 0d0)){ inv = +(inv, m) }
3333
RETURN(inv)
3434
}
3535
3636
! ---------- the hidden LCG (the secret being cracked) ----------
3737
! x_{n+1} = (a * x_n + c) mod m
3838
! The modulus is kept below 2^31 so that products of two consecutive
39-
! differences (each < m) never overflow Prefix's signed 64-bit INT.
40-
INT m = 0x186A1
41-
INT a = 0d16807
42-
INT c = 0d12345
43-
INT seed = 0d48271
39+
! differences (each < m) never overflow Prefix's signed 64-bit int.
40+
int m = 0x186A1
41+
int a = 0d16807
42+
int c = 0d12345
43+
int seed = 0d48271
4444
45-
FUNC INT step(INT s){
45+
func int step(int s){
4646
RETURN(MOD(+( *(a, s), c), m))
4747
}
4848
4949
! ---------- collect observed outputs (all the attacker sees) ----------
50-
MAP obs
51-
INT s = seed
50+
map obs
51+
int s = seed
5252
FOR(i, 0d8){
5353
obs<i> = s
5454
s = step(s)
@@ -60,17 +60,17 @@ DEL("s")
6060
! t_i = x_{i+1} - x_i follows t_{i+1} = a * t_i (mod m), so each
6161
! u_k = t_{k+1} * t_{k-1} - t_k^2 is a multiple of m. GCD of several
6262
! |u_k| yields m.
63-
MAP d
63+
map d
6464
FOR(i, 0d7){
6565
d<i> = -(obs<+(i, 0d1)>, obs<i>)
6666
}
6767
68-
INT mrec = 0d0
69-
INT k = 0d2
68+
int mrec = 0d0
69+
int k = 0d2
7070
WHILE(LTE(k, 0d6)){
71-
INT lo = -(k, 0d1)
72-
INT hi = +(k, 0d1)
73-
INT tk = d<k>
71+
int lo = -(k, 0d1)
72+
int hi = +(k, 0d1)
73+
int tk = d<k>
7474
mrec = GCD(mrec, ABS(-( *(d<hi>, d<lo>), *(tk, tk) )))
7575
k = +(k, 0d1)
7676
}
@@ -80,11 +80,11 @@ DEL("k")
8080
! ---------- recover a and c ----------
8181
! a = (x2 - x1) * (x1 - x0)^{-1} (mod m)
8282
! c = x1 - a * x0 (mod m)
83-
INT x0 = obs<0d1>
84-
INT x1 = obs<0d2>
85-
INT x2 = obs<0d3>
86-
INT arec = MOD(*( -(x2, x1), modinv(-(x1, x0), mrec) ), mrec)
87-
INT crec = MOD(-(x1, *(arec, x0)), mrec)
83+
int x0 = obs<0d1>
84+
int x1 = obs<0d2>
85+
int x2 = obs<0d3>
86+
int arec = MOD(*( -(x2, x1), modinv(-(x1, x0), mrec) ), mrec)
87+
int crec = MOD(-(x1, *(arec, x0)), mrec)
8888
IF(LT(arec, 0d0)){ arec = +(arec, mrec) }
8989
IF(LT(crec, 0d0)){ crec = +(crec, mrec) }
9090
DEL("r0")
@@ -100,8 +100,8 @@ DEL("x1")
100100
DEL("modinv")
101101
102102
! ---------- verify by regenerating the whole sequence ----------
103-
INT ok = 0d1
104-
INT v = x0
103+
int ok = 0d1
104+
int v = x0
105105
FOR(i, 0d8){
106106
IF(NEQ(v, obs<i>)){
107107
ok = 0d0
@@ -117,8 +117,8 @@ PRINT("cracked: m=", mrec, " a=", arec, " c=", crec)
117117
PRINT("sequence reproduced: ", ok)
118118
119119
! ---------- predict the next output ----------
120-
INT next_pred = MOD(+( *(arec, obs<0d8>), crec), mrec)
121-
INT next_true = step(obs<0d8>)
120+
int next_pred = MOD(+( *(arec, obs<0d8>), crec), mrec)
121+
int next_true = step(obs<0d8>)
122122
DEL("obs")
123123
DEL("step")
124124
PRINT("next output predicted: ", next_pred)

docs/CHANGELOG.html

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
### Minor-level changes
3434

3535
- Add operator `REFUTE`.
36-
- Add operator `ISMAP`.
37-
- Add operator `ISFUNC`.
38-
- Add operator `ISTHR`.
36+
- Add operator `ismap`.
37+
- Add operator `isfunc`.
38+
- Add operator `isthread`.
3939
- Allow `1` at ident start.
4040
- Update ident name rules.
4141
- Document `path` stdlib module.
@@ -55,33 +55,33 @@
5555

5656
Add a PowerShell-based automated test suite and run it in CI.
5757

58-
Fix `IADD` so coercing `NaN` and infinities to `INT` fails instead of succeeding.
58+
Fix `IADD` so coercing `NaN` and infinities to `int` fails instead of succeeding.
5959

6060
Fix `PAUSE` and its tests.
6161

6262
Fix `PARALLEL`.
6363

6464
Fix serialization and deserialization.
6565

66-
Make `MATCH` reject non-`INT` flags and accept later keyword arguments even when earlier optional ones are absent.
66+
Make `MATCH` reject non-`int` flags and accept later keyword arguments even when earlier optional ones are absent.
6767

68-
Make `WARN` reject empty calls and arguments that cannot be converted with `~STR`, and improve the empty-call error message.
68+
Make `WARN` reject empty calls and arguments that cannot be converted with `~str`, and improve the empty-call error message.
6969

70-
Make `PRINT` reject empty calls and arguments that cannot be converted with `~STR`.
70+
Make `PRINT` reject empty calls and arguments that cannot be converted with `~str`.
7171

7272
Reject multiple statements on one logical line.
7373

7474
Make `STRIP` treat `remove` as a substring rather than a character list, and reject an empty `remove` value.
7575

7676
Make `REPLACE` reject an empty `old` value.
7777

78-
Make `IN` reject tensor operands that are not `TNS` values.
78+
Make `IN` reject tensor operands that are not `tensor` values.
7979

80-
Make `STR` reject invalid operand types.
80+
Make `str` reject invalid operand types.
8181

8282
Make `KEYIN` reject invalid key types.
8383

84-
Make `BNOT` fail on non-binary `INT` values.
84+
Make `BNOT` fail on non-binary `int` values.
8585

8686
Make `THROW` concatenate its arguments.
8787

@@ -93,7 +93,7 @@
9393

9494
Fix `PARFOR` pointer writeback.
9595

96-
Fix tensor operator handling of `MAP` and `THR` values.
96+
Fix tensor operator handling of `map` and `thread` values.
9797

9898
Make `MOD` stop overwriting a pointer passed as its second operand.
9999

@@ -163,19 +163,19 @@
163163

164164
### Major-level changes
165165

166-
Add the first-class `BOOL` type with the `TRUE` and `FALSE` literals, and change the language's Boolean model to use `BOOL` rather than integer sentinel values.
166+
Add the first-class `bool` type with the `TRUE` and `FALSE` literals, and change the language's Boolean model to use `bool` rather than integer sentinel values.
167167

168-
Change built-in and standard-library APIs that previously returned `INT` sentinel values to return `BOOL` instead, including logical, comparison, type-checking, import, filesystem, console, freeze, and deletion operators, along with helpers such as `prime.IS_PRIME`, `prime.IS_MERSENNE_PRIME`, and `image.SHOW`.
168+
Change built-in and standard-library APIs that previously returned `int` sentinel values to return `bool` instead, including logical, comparison, type-checking, import, filesystem, console, freeze, and deletion operators, along with helpers such as `prime.IS_PRIME`, `prime.IS_MERSENNE_PRIME`, and `image.SHOW`.
169169

170170
### Minor-level changes
171171

172-
Bind `SELF` when calling `FUNC` values stored in `MAP` objects, preserving aliasing when the map is accessed through a pointer.
172+
Bind `SELF` when calling `func` values stored in `map` objects, preserving aliasing when the map is accessed through a pointer.
173173

174174
Update pointer semantics so transformed built-in results write back through pointer operands, and pointer arguments to user-defined functions bind as aliases.
175175

176176
### Patch-level changes
177177

178-
Allow `BOOL` values in conversions, truthiness, tensor elements, serialization, deserialization, printing, and default `FUNC` returns.
178+
Allow `bool` values in conversions, truthiness, tensor elements, serialization, deserialization, printing, and default `func` returns.
179179

180180
Fix image save operators to report runtime failures correctly.
181181

@@ -221,7 +221,7 @@
221221

222222
Complete `GOTO` implementation.
223223

224-
Ban implicit `MAP` returns from `FUNC`.
224+
Ban implicit `map` returns from `func`.
225225

226226
Ban non-ASCII chars from source code.
227227

@@ -239,19 +239,19 @@
239239

240240
Make `FOR` counter loop-local.
241241

242-
Ban `RETURN` from outside `FUNC`.
242+
Ban `RETURN` from outside `func`.
243243

244244
Fix [specification 9.2.3](https://python-processing-unit.github.io/Prefix/SPECIFICATION.html#923-conditional-statements).
245245

246-
Fix `MAP`'s Boolean representation.
246+
Fix `map`'s Boolean representation.
247247

248248
Ban invalid `^`.
249249

250250
Ban incorrect bracket kinds.
251251

252252
Fix [specification section 4.4.1](https://python-processing-unit.github.io/Prefix/SPECIFICATION.html#441-tensor-literals).
253253

254-
Restrict `GOTOPOINT` to `STR` and positive `INT`.
254+
Restrict `GOTOPOINT` to `str` and positive `int`.
255255

256256
Require parentheses for `CONTINUE`.
257257

@@ -281,7 +281,7 @@
281281

282282
Allow symbol creation via `ASSIGN`.
283283

284-
Allow `DEL` calls on `MAP` indexes.
284+
Allow `DEL` calls on `map` indexes.
285285

286286
Fix `-source` mode module name.
287287

@@ -311,7 +311,7 @@
311311

312312
### Major-level changes
313313

314-
Convert `INT` and `FLT` from binary types to support multiple bases.
314+
Convert `int` and `float` from binary types to support multiple bases.
315315

316316
### Minor-level changes
317317

@@ -339,7 +339,7 @@
339339

340340
### Patch-level changes
341341

342-
Convert `MAP` to use a hash table for performance.
342+
Convert `map` to use a hash table for performance.
343343

344344
---
345345

@@ -377,15 +377,15 @@
377377

378378
### Major-level changes
379379

380-
Make `TNS` and `MAP` atomic.
380+
Make `tensor` and `map` atomic.
381381

382382
### Minor-level changes
383383

384384
N/A
385385

386386
### Patch-level changes
387387

388-
Fix `FUNC` handling in `SIGNATURE`.
388+
Fix `func` handling in `SIGNATURE`.
389389

390390
---
391391

@@ -397,9 +397,9 @@
397397

398398
### Minor-level changes
399399

400-
Add `FLT` infinities.
400+
Add `float` infinities.
401401

402-
Add `FLT` NaN.
402+
Add `float` NaN.
403403

404404
### Patch-level changes
405405

0 commit comments

Comments
 (0)