Skip to content

jule: include functions #128

@koibtw

Description

@koibtw

Detailed description

Hey. I think having a function that would "include" data from files at compiletime (i.e. "embed" the file) would be really useful.
We don't have to have "include as code" (see Rust's include!()). The ones I care about are Rust's include_bytes!() and include_str!(). See the context below.
Opinions?

Context

Rust std's implementation:
https://doc.rust-lang.org/std/macro.include.html
https://doc.rust-lang.org/std/macro.include_bytes.html
https://doc.rust-lang.org/std/macro.include_str.html

Additional information

The usage would look something like this:

use "std/comptime"

static TEST_FILE_BYTES: []byte = comptime::IncludeBytes("test.txt")
static TEST_FILE_STR: str = comptime::IncludeStr("test.txt")

fn main() {
	println(TEST_FILE_STR)
}

// Doing this should work too:
use "std/comptime"

fn main() {
	testFileStr := comptime::IncludeStr("test.txt")
	println(testFileStr)
}

Outputs the contents of test.txt converted to str, read on compiletime.

If there are no objections, I'd be happy to work on this.

Metadata

Metadata

Assignees

Labels

proposalA proposal for new feature or changings

Type

No type

Projects

Status

Incoming

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions