gavr123456789 / Niva

Smalltalk like programming language
https://gavr123456789.github.io/niva-site
39 stars 2 forks source link

Feature pack: what needed to use Compose #175

Open gavr123456789 opened 9 months ago

gavr123456789 commented 9 months ago

Single param pragmas

Kotlin

@Composable fun sas() {}

Niva

current: @x: sas y: sus
new: @Composable Clonable
It can be a list of one words, or list of keywords, not both in one pragma @x: 1 y: 2 z: 3 or @sas sus clonable

Also

Kotlin

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun Button(...)

Niva

@OptIn: "ExperimentalMaterialApi::class"
@Composable
Button modifier::Modifier ...

Kinda done

with just @Serializable but there are a problem with imports(no autoimports for pragmas)

Extension lambdas

Kotlin

@Composable
inline fun Column(
    modifier: Modifier = Modifier,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    content: @Composable ColumnScope.() -> Unit // HERE
) {...}

Niva

Actually builders not so much different from lambda, if there was possible to make them toplevel

builder Column content::[this::ColumnScope -> Unit]

Default values?

Since there a lot of them

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun Button(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    elevation: ButtonElevation? = ButtonDefaults.elevation(),
    shape: Shape = MaterialTheme.shapes.small,
    border: BorderStroke? = null,
    colors: ButtonColors = ButtonDefaults.buttonColors(),
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    content: @Composable RowScope.() -> Unit
)

directives

val q by lazy {111}
q = 111 by: lazy
gavr123456789 commented 3 months ago

check can pragmas be used with qualifier to eliminate imports if so, then its possible to add pragmas on the bind state, like

Bind content: [
    @Compose
    builder Card card ...

]
gavr123456789 commented 3 months ago

by: can be represented as some method that returns an inlined block of code lazy ^= [a::T -> a] x by: lazy = [21 + 21] now x has type Int instead of Int -> Int, but it will be evaluated on call