iamgio / pikt Goto Github PK
View Code? Open in Web Editor NEW:art: Image-based poetic programming language.
License: GNU General Public License v3.0
:art: Image-based poetic programming language.
License: GNU General Public License v3.0
Hi, I'm an esoteric language enthusiast, and just wanted to say that it's the most interesting one I've seen (haven't tried it yet thought).
Have a nice day!
As of now, a struct (StructStatement
) in Pikt is transpiled to a Kotlin data class
, an improved kind of class that automatically generates some useful methods.
Referring to the wiki:
Generates the following Kotlin code:
data class `3600FF`(`30FF00`: Any = 0, `FF6C00`: Any = 0)
var `72F0FF` = `3600FF`()
For simplicity, let's use human-readable names:
data class MyStruct(first: Any = 0, second: Any = 0)
var struct = MyStruct()
Kotlin has automatic typing, so struct
is a MyStruct
at compile time. The problem arises when Pikt's dynamic typing comes: function parameters are Any
at compile time (equivalent to Object
in Java). A function in Pikt looks like this when converted to Kotlin:
fun myFunc(arg: Any) {
// body
}
So arg
has little to none information at compile time, but can be used with ease thanks to Pikt's Kotlin libraries that take only Any
arguments. But what libraries cannot handle is what the .
does. Take this:
data class MyStruct(first: Any = 0, second: Any = 0)
var struct = MyStruct()
fun myFunc(arg: Any) {
print(arg.first)
}
myFunc(struct)
This leads to a compile error because arg
is obviously not a MyStruct
, yet we want it to be.
I'm currently considering multiple options:
String
-Any
(hash)maps, with color names as keys.var MyStruct = mapOf("first" to 0, "second" to 0)
fun myFunc(arg: Any) {
print(arg["first"]) // 'get' can be overridden
}
myFunc(struct)
fun myFunc(arg: Any) {
arg as MyStruct // Similar to an assert
print(arg.first)
}
Like 2, but manual via a specific statement that casts the type of a variable to its struct class.
Pros: same as 2.
Cons: a new statement to put often in Pikt sources.
Fields can be accessed via reflection: Pikt's dot
operator could generate a function instead of a .
, for example arg.dot(first)
in order to retrieve the value via reflection.
Pros: easy to implement, no typing issues.
Cons: reflection should be avoided when possible, inline set wouldn't work.
It would be nice to be able to specify multiple colors for one instruction and/or ranges, let's say all grays are whitespace.
Since 9b0584f eu.iamgio.pikt.compiler.AbstractCompiler
exposes the handleInput(stdin)
function that allows writing to the Kotlin compiler's stdin from Pikt's CLI.
The main implementation is handled by eu.iamgio.pikt.compiler.Interpreter
. It lets the user interact with the Kotlin script interpreter via Pikt's standard input.
A common scenario would be calling Pikt's readInput()
function (defined in the stdlib) and expecting some input from the command line.
The issue is that, on Pikt's side, the stream keeps looking for some new input and keeps the process alive, despite being in another thread. When it's fed with a line, the stream is already closed and leads to an IOException
.
The stdin is being temporarily locked again (the function call from AbstractCompiler
was commented out) until a solution is found. Any kind of help would be highly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.