marianoguerra / efene

OFICIAL REPO IS AT https://github.com/efene/efene
https://github.com/efene/efene
Other
145 stars 32 forks source link

Feature request: public block syntax #47

Closed DavidMikeSimon closed 12 years ago

DavidMikeSimon commented 12 years ago

Looking over some of my Efene code, I mostly have all my exported functions in one section of each file, and the internal functions in another. This suggests a possible improved syntax:

Efene:

  @public {
    my_exported_foo = fn() {
      ...
    }
    another_export_bar = fn() {
      ...
    }
  }
  some_private_func = fn() {
    ...
  }

Ifene:

  @public 
    my_exported_foo = fn()
      ...
    another_exported_bar = fn()
      ...
  some_private_func = fn
    ...
marianoguerra commented 12 years ago

since @ public is just a local attribute (http://marianoguerra.com.ar/efene/docs/reference/toplevel/localattrs.html) that would require special syntax for a very special case.

the other option you have (which I think it will be worst, it's to use global attributes like erlang):

@@export([foo => 0, bar => 0])                                             

foo = fn                                                                   
    io.format("foo~n")                                                     

bar = fn                                                                   
    io.format("bar~n")                                                     

@public                                                                    
run = fn                                                                   
    foo()                                                                  
    bar()   
DavidMikeSimon commented 12 years ago

I must disagree about it being a special case; the public local attribute will certainly be the most commonly used. Additionally, even though that would be the most common usage, the syntax can be generic. Suppose I implemented this change as a general feature, such that:

@foo {
  bar = fn() {}
  baz = fn() {}
}

is equivalent for any value of foo to:

@foo 
bar = fn() {}

@foo 
baz  = fn() {}

Would you accept a pull request with such a change?

marianoguerra commented 12 years ago

On Mon, Dec 26, 2011 at 6:35 PM, David Simon < reply@reply.github.com

wrote:

I must disagree about it being a special case; the public local attribute will certainly be the most commonly used. Additionally, even though that would be the most common usage, the syntax could be more generic than that. Suppose I implemented this change as a general feature, such that:

@foo {
 bar = fn() {}
 baz = fn() {}
}

were equivalent to:

@foo
bar = fn() {}

@foo
baz  = fn() {}

Would you accept a pull request with such a change?

I'm okay with a grouping attribute, I don't like the braces proposal, I will think syntax alternatives (and you can propose them too :)

DavidMikeSimon commented 12 years ago

Well, the reason I was thinking of braces is because that's what allows the use of indentation in Ifene, right?

-- David Simon On Jan 8, 2012 10:42 AM, "Mariano Guerra" < reply@reply.github.com> wrote:

On Mon, Dec 26, 2011 at 6:35 PM, David Simon < reply@reply.github.com

wrote:

I must disagree about it being a special case; the public local attribute will certainly be the most commonly used. Additionally, even though that would be the most common usage, the syntax could be more generic than that. Suppose I implemented this change as a general feature, such that:

@foo {
 bar = fn() {}
 baz = fn() {}
}

were equivalent to:

@foo
bar = fn() {}

@foo
baz  = fn() {}

Would you accept a pull request with such a change?

I'm okay with a grouping attribute, I don't like the braces proposal, I will think syntax alternatives (and you can propose them too :)


Reply to this email directly or view it on GitHub: https://github.com/marianoguerra/efene/issues/47#issuecomment-3402629

marianoguerra commented 12 years ago

On Sun, Jan 8, 2012 at 4:08 PM, David Simon < reply@reply.github.com

wrote:

Well, the reason I was thinking of braces is because that's what allows the use of indentation in Ifene, right?

yes, but attributes are special, they are not a block expression, they just apply to the function below or to the whole file.