Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

ftd.space and ftd.empty rfc #194

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FASTN.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ favicon: /-/fastn.com/images/favicon.svg
- 4: Incremental Build
url: /rfc/incremental-build/
document: rfcs/0004-incremental-build.ftd
- 5: `ftd.space` and `ftd.empty`
url: /rfc/ftd-space/
document: rfcs/0005-ftd-space.ftd
- Architecture: /architecture/
document: d/architecture.ftd
- `ftd` crate 🚧: /ftd-crate/
Expand Down
112 changes: 112 additions & 0 deletions rfcs/0005-ftd-space.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
-- import: fastn.com/rfcs/lib

-- lib.rfc: RFC-5: Introducing `ftd.space` and `ftd.empty` Variables to `ftd`
id: 0005-ftd-space
status: pending

The purpose of this RFC is to propose the introduction of two new variables,
`ftd.space` and `ftd.empty`, to the `ftd` library. These variables will
facilitate the insertion of space characters and empty strings.


-- lib.motivation:

The addition of `ftd.space` and `ftd.empty` variables simplifies the process of
adding space character and empty space. By providing these predefined variables
for common formatting needs, makes `ftd` becomes more user-friendly when working
with spacing and empty content.

The `ftd.empty` can be used as default value of string type variable. This
variable can later on append other strings on some events.
Comment on lines +14 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should mention how our grammar does not allow people to create space or empty strings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need motivation for why we need space and empty string. What are the use cases?


-- end: lib.motivation



-- lib.detailed-design:

`ftd` will now contains two predefined variables. These will be included in
`default bag` in interpreter.
Comment on lines +28 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not mention technical implementation in RFC. Remove the default bag bit.


-- ds.h2: Variables Definition

-- ds.h3: `ftd.space`

The `ftd.space` variable is defined to return a space character as a string.

-- ds.h3: `ftd.empty`

The `ftd.empty` variable is defined to return an empty string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change line to: The ftd.empty variable contains empty string. Also change the ftd.space. Variables do not return things. Functions return things.


-- ds.h2: Usage

The `ftd.space` variable can be used as the text for `ftd.text` element to
insert a space character and the `ftd.empty` variable can be used to insert an
empty string into the output. Here's an example of its usage:

-- ds.code:
lang: ftd

\-- ftd.text: $ftd.space
\-- ftd.text: $ftd.empty

-- end: lib.detailed-design




-- lib.alternatives:

-- ds.h2: Rejected: Adding the `ftd.space` function to `ftd`

The earlier proposal was the addition of the `ftd.space` function to the `ftd`
library. This function aims to generate strings containing a specified number of
space characters.

-- ds.code:
lang: js

ftd.space = function(arg) {
let __arg__ = {
a: 0,
...arg
};
if (__arg__.a <= 0) {
return '';
}

return ' '.repeat(__arg__.a);
}
Comment on lines +69 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also tech/implementation detail. RFC should not include implementation details, only end user stuff.


-- ds.markdown:

We rejected this because this has barely any use besides for the above two
mentioned cases. There's hardly any chance to use it for adding more than one
space.


-- end: lib.alternatives




-- lib.teaching-notes:

The introduction of `ftd.space` and `ftd.empty` variables can be effectively
integrated into educational material for `ftd` users.

-- end: lib.teaching-notes




-- lib.unresolved-questions:

As of now, there are no unresolved questions or issues related to the proposal
of introducing `ftd.space` and `ftd.empty` variables to the ftd library.
Comment on lines +105 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One unresolved question is can we fix our grammar so that this is not needed. This is a limitation of our grammar after all.


-- end: lib.unresolved-questions



-- end: lib.rfc