Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Suggestion: Use and Expand list literals in code (compile time) #24

Open
kobi2187 opened this issue Nov 4, 2015 · 10 comments
Open

Suggestion: Use and Expand list literals in code (compile time) #24

kobi2187 opened this issue Nov 4, 2015 · 10 comments

Comments

@kobi2187
Copy link

kobi2187 commented Nov 4, 2015

When looking for packages or including interfaces, use the list literal [ list literal ]. And then expand to single lines.

class @ :: Hello :: World
  def @main() do new @@()

  def new()
    hello()
    world()
  end
end

the first line becomes:
class @ :: [ Hello , World ]

the same should be done for import.

import openfl.display.Bitmap
import openfl.display.Sprite
import openfl.events.Event
import openfl.events.KeyboardEvent
import openfl.ui.Keyboard
import openfl.Assets

can be written as:

import openfl.display.[ Bitmap, Sprite ]
import openfl.events.[ Event, KeyboardEvent ]
import openfl.ui.Keyboard
import openfl.Assets

This means to parse the line and create multiple lines according to the list part.
that is, expand it.

other possibilities for syntax:

  • slash - because it signifies directories:
    import openfl/events/[ Event, KeyboardEvent ]
  • Allow regular expressions between parts:
    import openfl.(events|ui).something #something is in both of them.
    can have other .* regular expressions.
    This will mean that raxe will have to scan the directories or packages to retrieve everything that matches.

While we're on this subject of reducing code amount, the word "import" repeats every line.
what do you think about something along these lines?

import {
    openfl.display.[ Bitmap, Sprite ]
    openfl.events.[ Event, KeyboardEvent ]
    openfl.ui.Keyboard
    openfl.Assets
}

seems cleaner to me

@escargotprodige
Copy link

👍 That is an amazing idea 😄

@escargotprodige
Copy link

This is my suggestion for the last one. It reduces even more code & looks more like raxe syntax 😄

import
  openfl: 
    display: Bitmap, Sprite
    events: Event, KeyboardEvent
    ui: Keyboard
    Assets
end

@kobi2187
Copy link
Author

kobi2187 commented Nov 5, 2015

wow, I like your style. very aesthetic!

@escargotprodige
Copy link

Following the same idea, this:

import luxe.Input
import luxe.Scene
import luxe.Sprite
import luxe.Visual
import luxe.Color
import luxe.Vector
import luxe.AppConfig
import luxe.Particles
import luxe.Entity
import luxe.Text
import luxe.structural.Pool
import luxe.structural.Bag
import luxe.options.GeometryOptions

import states.*

import mint.Control
import mint.types.Types
import mint.render.luxe.LuxeMintRender
import mint.render.luxe.Convert
import mint.layout.margins.Margins

would become:

import 
  states: *
  mint:
    render.luxe: LuxeMintRenderer, Convert
    layout.margins: Margins
    types: Types
    Control
  luxe:
    structural: Pool, Bag
    options: GeometryOptions
    Input, Scene, Sprite
    Visual, Color, Vector
    AppConfig, Particles, Entity
    Text
end

@kobi2187
Copy link
Author

kobi2187 commented Nov 5, 2015

👍 very cool.
one last final touch: I notice that package and class names can't have spaces in them,
so it will not be ambiguous to remove the ',' commas and use whitespace (space or tabs) as separation.
ok, maybe i'm taking this too far already.
I like your syntax suggestions they look nicer than the original proposal in my opinion. good job :-)

@escargotprodige
Copy link

Thanks 😃
In my opinion, I think the separation is easier to see with the commas, but it could be optional, so it fits everyone's style 😄

@deathbeam
Copy link
Owner

This

import 
  states: *
  mint:
    render.luxe: LuxeMintRenderer, Convert
    layout.margins: Margins
    types: Types
    Control
  luxe:
    structural: Pool, Bag
    options: GeometryOptions
    Input, Scene, Sprite
    Visual, Color, Vector
    AppConfig, Particles, Entity
    Text
end

Looks more like CoffeeScript object notation, what about this? I know I am adding useless things there, but it is just because to make sense

import [
  openfl.[
    display.[ Bitmap, Sprite ],
    events.[ Event, KeyboardEvent ],
    ui.Keyboard,
    Assets,
  ]
]

So the first example would become this:

import [
  states.*,
  mint.[
    render.luxe.[LuxeMintRenderer, Convert],
    layout.margins.Margins,
    types.Types,
    Control,
  ], luxe.[
    structural.[Pool, Bag],
    options.[GeometryOptions],
    Input, Scene, Sprite,
    Visual, Color, Vector,
    AppConfig, Particles, Entity,
    Text,
  ],
]

@escargotprodige
Copy link

I think that both of the solutions are great, the only problem is that there is not enough people to discuss about it 😟
To me, the fact that it looks like CoffeeScript object litterals doesn't really matter. In fact, I think looks cleaner.

But like I said, there should be more people to discuss about that 😄

@escargotprodige
Copy link

I think we should improve the LiveScript require! syntax so that it fits Spoon and Haxe to reduce the ammount of import statements.
I hate big import lists and the current Spoon syntax for import statements doesn't help 😄

@escargotprodige
Copy link

Regarding the new syntax for import, I've reworked the syntax found here and opened #26 so that we can discuss it together :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants