[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] std.pk: Add `get_mem_handle`
|
From: |
Mohammad-Reza Nabipoor |
|
Subject: |
[PATCH] std.pk: Add `get_mem_handle` |
|
Date: |
Sat, 9 Apr 2022 22:37:13 +0430 |
2022-04-09 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/std.pk (get_mem_handle): New function to get a new
unique handle for memory IOS.
(__Pk_MemHandle_Generator): New implementation-specific type.
---
Hello.
This can be useful for `with_cur_ios`:
```poke
type void_lambda = () void;
fun with_cur_ios = (void_lambda callback = lambda void: {},
string handle = get_mem_handle) void:
{
/* ... */
}
```
WDYT?
Regards,
Mohammad-Reza
ChangeLog | 6 ++++++
libpoke/std.pk | 10 ++++++++++
2 files changed, 16 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index f4f5278f..a1b771d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-04-09 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/std.pk (get_mem_handle): New function to get a new
+ unique handle for memory IOS.
+ (__Pk_MemHandle_Generator): New implementation-specific type.
+
2022-04-09 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pvm.h (pvm_assert_full): New function.
diff --git a/libpoke/std.pk b/libpoke/std.pk
index df70be27..f69f4828 100644
--- a/libpoke/std.pk
+++ b/libpoke/std.pk
@@ -403,3 +403,13 @@ fun eoffset = (any v, string n) offset<uint<64>,b>:
return v'eoffset (i);
raise E_inval;
}
+
+/* Give a unique handle for memory IOS. */
+
+type __Pk_MemHandle_Generator = () string;
+var get_mem_handle = lambda __Pk_MemHandle_Generator:
+ {
+ var n = 0;
+
+ return lambda string: { return format ("*__tmp%i32d*", n++); };
+ } ();
--
2.35.1
- [PATCH] std.pk: Add `get_mem_handle`,
Mohammad-Reza Nabipoor <=