Does Lua have a Roadmap?

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Does Lua have a Roadmap?

Italo Maia
Which new features are to be expected for lua? Classes, strong typing, arrow function, list comprehension, etc.
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Luiz Henrique de Figueiredo
> Which new features are to be expected for lua? Classes, strong typing,
> arrow function, list comprehension, etc.

None of these is planned for a future version of Lua.
See also https://www.lua.org/faq.html#1.4 .

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Italo Maia
Well, out of the features mentioned, strong typing would be a simplification of the language, by all means. Anyway ... a roadmap would be nice.

2017-06-18 16:05 GMT-03:00 Luiz Henrique de Figueiredo <[hidden email]>:
> Which new features are to be expected for lua? Classes, strong typing,
> arrow function, list comprehension, etc.

None of these is planned for a future version of Lua.
See also https://www.lua.org/faq.html#1.4 .




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Coda Highland
On Mon, Jun 19, 2017 at 2:15 PM, Italo Maia <[hidden email]> wrote:
> Well, out of the features mentioned, strong typing would be a simplification
> of the language, by all means. Anyway ... a roadmap would be nice.

Two things:

(1) Lua is already strongly typed. It just has a very small list of
recognized types, and one of those types is "table".

(2) Stronger typing than this would not simplify the language
whatsoever. It would require a mechanism by which user-defined types
can be added as well as mechanisms by which these types can be
identified, manipulated, and instantiated. You could reasonably argue
that it might make the language more ROBUST, but it would not by any
means be SIMPLER.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Italo Maia
(1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a weakly typed language behavior?
(2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw here, it would be easier to understand than the given behavior.


2017-06-19 17:35 GMT-03:00 Coda Highland <[hidden email]>:
On Mon, Jun 19, 2017 at 2:15 PM, Italo Maia <[hidden email]> wrote:
> Well, out of the features mentioned, strong typing would be a simplification
> of the language, by all means. Anyway ... a roadmap would be nice.

Two things:

(1) Lua is already strongly typed. It just has a very small list of
recognized types, and one of those types is "table".

(2) Stronger typing than this would not simplify the language
whatsoever. It would require a mechanism by which user-defined types
can be added as well as mechanisms by which these types can be
identified, manipulated, and instantiated. You could reasonably argue
that it might make the language more ROBUST, but it would not by any
means be SIMPLER.

/s/ Adam




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Parke
In reply to this post by Luiz Henrique de Figueiredo
>> Which new features are to be expected for lua? Classes, strong typing,
>> arrow function, list comprehension, etc.

On Sun, Jun 18, 2017 at 12:05 PM, Luiz Henrique de Figueiredo
<[hidden email]> wrote:
> None of these is planned for a future version of Lua.
> See also https://www.lua.org/faq.html#1.4 .

The FAQ does not mention any specifics.

Are the Lua authors at present contemplating any changes whatsoever
for a future version of Lua, be it either 5.4 or 6.0?  I ask because I
am not aware of what those changes might be.  In years past, I was
aware of discussions about _ENV, integers, goto, etc.  But all those
changes have been made and are in Lua 5.3.  I have absolutely no idea
what sort of possible future features, if any, are being contemplated
or considered.

I have heard (vague?) talk about:

1) Moving LPeg into Lua.
2) Adding macros.
3) Adding a JIT.

Regrading LPeg: At a glance, I don't see the benefits.  LPeg seems to
work just fine as a module.

Regarding macros: I don't remember hearing any specific proposals.
And discussion of macros may have been many years ago.

Regarding a JIT:  My sense is the Lua authors have other priorities.

So... I really have no idea what might be added in Lua 5.4 or Lua 6.0.

Cheers,

Parke

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

nobody
In reply to this post by Italo Maia
On 2017-06-19 23:49, Italo Maia wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?
> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw
> here, it would be easier to understand than the given behavior.

#define LUA_NOCVTS2N

(And yes, I've used that a bunch of times.  But I also occasionally use
the implicit conversion -- both have their uses.)

-- nobody

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Jorge Eduardo
In reply to this post by Italo Maia
Em 19 de jun de 2017 18:50, "Italo Maia" <[hidden email]> escreveu:
(1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a weakly typed language behavior?
(2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw here, it would be easier to understand than the given behavior.

Dear Italo,
This behavior is called String Coercion.

Lua performs automatic conversion of numbers to strings and vice versa where it is appropriate. This is called coercion.
> = "This is Lua version " .. 5.1 .. " we are using."
This is Lua version 5.1 we are using.
> = "Pi = " .. math.pi
Pi = 3.1415926535898
> = "Pi = " .. 3.1415927
Pi = 3.1415927

Jorge Eduardo de A. Oliveira
Computer Science Undergraduate Student

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Coda Highland
In reply to this post by Italo Maia
On Mon, Jun 19, 2017 at 4:49 PM, Italo Maia <[hidden email]> wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?
> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw
> here, it would be easier to understand than the given behavior.

(1) In this case, it's a strongly-typed behavior. It's not treating
strings and numbers as interchangeable; it's an explicitly documented
behavior of the + operator, and there's a separate concatenation
operator that has different semantics (number .. number -> string).
This isn't like PHP where strings that look like numbers effectively
ARE numbers and all sorts of bizarre things can happen with them. It's
more like how C++ tries to find a type conversion to a function that
doesn't directly support the types you used.

(2) No, string plus number equals number, which can compare to another
number. Lua does not have a distinct integer type; it didn't have an
integer type _at all_ until 5.3 and that's a subtype with well-defined
conversion rules (it coerces to a floating-point number very readily).

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Italo Maia
In reply to this post by Jorge Eduardo
Dear Italo,
This behavior is called String Coercion.

Thanks, Edu, I'm aware. The thing is that this implicit coercion is a weakly typed language behavior for what I know. "Usually" not a good thing. See this example:

'5' * 5  # one could expect it to create a string with five 5 characters. In lua, it gives you 25

#define LUA_NOCVTS2N

So, I can compile lua to not allow the string + number operation? Is that it? Nice to know. Seems an interesting approach for embeded devices. Was that your use case?

Parke, I too believe a roadmap is a great way to align expectations. Knowing what is to come is very helpful on the long run. VERY!


2017-06-19 19:05 GMT-03:00 Edu Araújo <[hidden email]>:
Em 19 de jun de 2017 18:50, "Italo Maia" <[hidden email]> escreveu:
(1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a weakly typed language behavior?
(2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw here, it would be easier to understand than the given behavior.

Dear Italo,
This behavior is called String Coercion.

Lua performs automatic conversion of numbers to strings and vice versa where it is appropriate. This is called coercion.
> = "This is Lua version " .. 5.1 .. " we are using."
This is Lua version 5.1 we are using.
> = "Pi = " .. math.pi
Pi = 3.1415926535898
> = "Pi = " .. 3.1415927
Pi = 3.1415927

Jorge Eduardo de A. Oliveira
Computer Science Undergraduate Student




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Italo Maia
In reply to this post by Coda Highland
(1) it's an explicitly documented behavior of the + operator

I'm unsure if documenting it makes it "ok" to use and still be consider it strongly typed. Javascript would kind of splash close in that pool. But the string concatenation operator does add some spice to the mix.

> -- lua 5.3
> 5+'5'
10.0
> 5+5
10
> 10.0 == 10
true
> tostring(5+'5') == tostring(5+5)
false
> 5 .. '5'
55
>> 5 .. 5
55
> tostring(5..'5') == tostring(5..5)
true
> 5..5
error
> '5'..'5'
55
> 5*5
25
> '5'*'5'
25

Well, the examples above leave some room for thought.


2017-06-19 19:16 GMT-03:00 Coda Highland <[hidden email]>:
On Mon, Jun 19, 2017 at 4:49 PM, Italo Maia <[hidden email]> wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?
> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw
> here, it would be easier to understand than the given behavior.

(1) In this case, it's a strongly-typed behavior. It's not treating
strings and numbers as interchangeable; it's an explicitly documented
behavior of the + operator, and there's a separate concatenation
operator that has different semantics (number .. number -> string).
This isn't like PHP where strings that look like numbers effectively
ARE numbers and all sorts of bizarre things can happen with them. It's
more like how C++ tries to find a type conversion to a function that
doesn't directly support the types you used.

(2) No, string plus number equals number, which can compare to another
number. Lua does not have a distinct integer type; it didn't have an
integer type _at all_ until 5.3 and that's a subtype with well-defined
conversion rules (it coerces to a floating-point number very readily).

/s/ Adam




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Soni "They/Them" L.
In reply to this post by Italo Maia


On 2017-06-19 06:49 PM, Italo Maia wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?

This is called operator overloading, not weak typing. More specifically,
operator +, when applied to a string and any number type, results in the
conversion of the string to a float, followed by (float) addition.

Take a look at this Rust code, for example:

use std::ops::Add;
struct LuaString<'a>(&'a str);
struct LuaInt(i64);
struct LuaFloat(f64);
impl<'a> Add<LuaInt> for LuaString<'a> {
     type Output = Option<LuaFloat>;
     fn add(self, i: LuaInt) -> Option<LuaFloat> {
         self.0.parse::<f64>().ok().map(|x| LuaFloat(x + (i.0 as f64)))
     }
}
fn main() {
   (LuaString("5") + LuaInt(5)).map_or_else(|| println!("nil"), |x|
println!("{}", x.0))
}

(run it on your browser:
https://play.rust-lang.org/?gist=1f4e2f3b2486870d628110eafd4c73e6&version=stable&backtrace=2 
)

It takes a LuaString and a LuaInt and turns them into a LuaFloat, yet
it's *strongly* typed AND *statically* typed.
(note: Rust doesn't add ".0" when printing floats like Lua does. but
it's still a float.)

> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was
> throw here, it would be easier to understand than the given behavior.

With stronger typing, you still wouldn't get an error.

>
>
> 2017-06-19 17:35 GMT-03:00 Coda Highland <[hidden email]
> <mailto:[hidden email]>>:
>
>     On Mon, Jun 19, 2017 at 2:15 PM, Italo Maia <[hidden email]
>     <mailto:[hidden email]>> wrote:
>     > Well, out of the features mentioned, strong typing would be a
>     simplification
>     > of the language, by all means. Anyway ... a roadmap would be nice.
>
>     Two things:
>
>     (1) Lua is already strongly typed. It just has a very small list of
>     recognized types, and one of those types is "table".
>
>     (2) Stronger typing than this would not simplify the language
>     whatsoever. It would require a mechanism by which user-defined types
>     can be added as well as mechanisms by which these types can be
>     identified, manipulated, and instantiated. You could reasonably argue
>     that it might make the language more ROBUST, but it would not by any
>     means be SIMPLER.
>
>     /s/ Adam
>
>
>
>
> --
> "A arrogância é a arma dos fracos."
>
> ===========================
> Me. Italo Moreira Campelo Maia
> Co-fundador do Grupo de Usuários Python do Ceará
> Secretário ForHacker (fb.com/ForHackerSpace
> <http://fb.com/ForHackerSpace>)
> Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
> -----------------------------------------------------
> Meu Livro <http://bit.ly/flask-amazon>, Site
> <http://www.italomaia.com/>, Blog <http://eusouolobomau.blogspot.com/>
> ===========================

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.


Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Andrew Starks-2
In reply to this post by Italo Maia

On Mon, Jun 19, 2017 at 17:52 Italo Maia <[hidden email]> wrote:
(1) it's an explicitly documented behavior of the + operator

I'm unsure if documenting it makes it "ok" to use and still be consider it strongly typed. Javascript would kind of splash close in that pool. But the string concatenation operator does add some spice to the mix.

> -- lua 5.3
> 5+'5'
10.0
> 5+5
10
> 10.0 == 10
true
> tostring(5+'5') == tostring(5+5)
false
> 5 .. '5'
55
>> 5 .. 5
55
> tostring(5..'5') == tostring(5..5)
true
> 5..5
error
> '5'..'5'
55
> 5*5
25
> '5'*'5'
25

Well, the examples above leave some room for thought.

The thought that I had was, "yup. That seems clear to me." Putting all of the possibilities next to each other makes for a good exercise though. 



2017-06-19 19:16 GMT-03:00 Coda Highland <[hidden email]>:
On Mon, Jun 19, 2017 at 4:49 PM, Italo Maia <[hidden email]> wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?
> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw
> here, it would be easier to understand than the given behavior.

(1) In this case, it's a strongly-typed behavior. It's not treating
strings and numbers as interchangeable; it's an explicitly documented
behavior of the + operator, and there's a separate concatenation
operator that has different semantics (number .. number -> string).
This isn't like PHP where strings that look like numbers effectively
ARE numbers and all sorts of bizarre things can happen with them. It's
more like how C++ tries to find a type conversion to a function that
doesn't directly support the types you used.

(2) No, string plus number equals number, which can compare to another
number. Lua does not have a distinct integer type; it didn't have an
integer type _at all_ until 5.3 and that's a subtype with well-defined
conversion rules (it coerces to a floating-point number very readily).

/s/ Adam




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Italo Maia
Ok ... then, could someone provide an example of a weakly typed language? If there is no problem to operate on different types because the operation is defined, I'm quite unsure of what could be weakly typed.

2017-06-19 20:00 GMT-03:00 Andrew Starks <[hidden email]>:

On Mon, Jun 19, 2017 at 17:52 Italo Maia <[hidden email]> wrote:
(1) it's an explicitly documented behavior of the + operator

I'm unsure if documenting it makes it "ok" to use and still be consider it strongly typed. Javascript would kind of splash close in that pool. But the string concatenation operator does add some spice to the mix.

> -- lua 5.3
> 5+'5'
10.0
> 5+5
10
> 10.0 == 10
true
> tostring(5+'5') == tostring(5+5)
false
> 5 .. '5'
55
>> 5 .. 5
55
> tostring(5..'5') == tostring(5..5)
true
> 5..5
error
> '5'..'5'
55
> 5*5
25
> '5'*'5'
25

Well, the examples above leave some room for thought.

The thought that I had was, "yup. That seems clear to me." Putting all of the possibilities next to each other makes for a good exercise though. 



2017-06-19 19:16 GMT-03:00 Coda Highland <[hidden email]>:
On Mon, Jun 19, 2017 at 4:49 PM, Italo Maia <[hidden email]> wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?
> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw
> here, it would be easier to understand than the given behavior.

(1) In this case, it's a strongly-typed behavior. It's not treating
strings and numbers as interchangeable; it's an explicitly documented
behavior of the + operator, and there's a separate concatenation
operator that has different semantics (number .. number -> string).
This isn't like PHP where strings that look like numbers effectively
ARE numbers and all sorts of bizarre things can happen with them. It's
more like how C++ tries to find a type conversion to a function that
doesn't directly support the types you used.

(2) No, string plus number equals number, which can compare to another
number. Lua does not have a distinct integer type; it didn't have an
integer type _at all_ until 5.3 and that's a subtype with well-defined
conversion rules (it coerces to a floating-point number very readily).

/s/ Adam




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================



--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Italo Maia
Thanks for the example, Soni. Although I cannot read rust to save my life (nor mandarin, as a matter of fact), I understand what you put there. It still seems vague when a language can be considered strong or weakly typed. In my understanding, if all operations defined in the language only work with the same type (number and number, string and string, etc), unless explicitly defined otherwise, it is strong typed.

2017-06-19 20:04 GMT-03:00 Italo Maia <[hidden email]>:
Ok ... then, could someone provide an example of a weakly typed language? If there is no problem to operate on different types because the operation is defined, I'm quite unsure of what could be weakly typed.

2017-06-19 20:00 GMT-03:00 Andrew Starks <[hidden email]>:

On Mon, Jun 19, 2017 at 17:52 Italo Maia <[hidden email]> wrote:
(1) it's an explicitly documented behavior of the + operator

I'm unsure if documenting it makes it "ok" to use and still be consider it strongly typed. Javascript would kind of splash close in that pool. But the string concatenation operator does add some spice to the mix.

> -- lua 5.3
> 5+'5'
10.0
> 5+5
10
> 10.0 == 10
true
> tostring(5+'5') == tostring(5+5)
false
> 5 .. '5'
55
>> 5 .. 5
55
> tostring(5..'5') == tostring(5..5)
true
> 5..5
error
> '5'..'5'
55
> 5*5
25
> '5'*'5'
25

Well, the examples above leave some room for thought.

The thought that I had was, "yup. That seems clear to me." Putting all of the possibilities next to each other makes for a good exercise though. 



2017-06-19 19:16 GMT-03:00 Coda Highland <[hidden email]>:
On Mon, Jun 19, 2017 at 4:49 PM, Italo Maia <[hidden email]> wrote:
> (1) '5' + 5 gives you an 10.0 in the interactive console. Isn't this a
> weakly typed language behavior?
> (2) '5' + 5 > 10.0, string plus integer equals float. If an error was throw
> here, it would be easier to understand than the given behavior.

(1) In this case, it's a strongly-typed behavior. It's not treating
strings and numbers as interchangeable; it's an explicitly documented
behavior of the + operator, and there's a separate concatenation
operator that has different semantics (number .. number -> string).
This isn't like PHP where strings that look like numbers effectively
ARE numbers and all sorts of bizarre things can happen with them. It's
more like how C++ tries to find a type conversion to a function that
doesn't directly support the types you used.

(2) No, string plus number equals number, which can compare to another
number. Lua does not have a distinct integer type; it didn't have an
integer type _at all_ until 5.3 and that's a subtype with well-defined
conversion rules (it coerces to a floating-point number very readily).

/s/ Adam




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================



--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================



--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================
Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Soni "They/Them" L.


On 2017-06-19 08:11 PM, Italo Maia wrote:
> Thanks for the example, *Soni*. Although I cannot read rust to save my
> life (nor mandarin, as a matter of fact), I understand what you put
> there. It still seems vague when a language can be considered strong
> or weakly typed. In my understanding, if all operations defined in the
> language only work with the same type (number and number, string and
> string, etc), unless explicitly defined otherwise, it is strong typed.

Does this mean functions should only ever accept other functions for
arguments, otherwise it's not strong typed?

>
> 2017-06-19 20:04 GMT-03:00 Italo Maia <[hidden email]
> <mailto:[hidden email]>>:
>
>     Ok ... then, could someone provide an example of a weakly typed
>     language? If there is no problem to operate on different types
>     because the operation is defined, I'm quite unsure of what could
>     be weakly typed.
>
>     2017-06-19 20:00 GMT-03:00 Andrew Starks <[hidden email]
>     <mailto:[hidden email]>>:
>
>
>         On Mon, Jun 19, 2017 at 17:52 Italo Maia <[hidden email]
>         <mailto:[hidden email]>> wrote:
>
>                 (1) it's an explicitly documented behavior of the +
>                 operator
>
>
>             I'm unsure if documenting it makes it "ok" to use and
>             still be consider it strongly typed. Javascript would kind
>             of splash close in that pool. But the string concatenation
>             operator does add some spice to the mix.
>
>             > -- lua 5.3
>             > 5+'5'
>             10.0
>             > 5+5
>             10
>             > 10.0 == 10
>             true
>             > tostring(5+'5') == tostring(5+5)
>             false
>             > 5 .. '5'
>             55
>             >> 5 .. 5
>             55
>             > tostring(5..'5') == tostring(5..5)
>             true
>             > 5..5
>             error
>             > '5'..'5'
>             55
>             > 5*5
>             25
>             > '5'*'5'
>             25
>
>             Well, the examples above leave some room for thought.
>
>
>         The thought that I had was, "yup. That seems clear to me."
>         Putting all of the possibilities next to each other makes for
>         a good exercise though.
>
>
>
>
>             2017-06-19 19:16 GMT-03:00 Coda Highland
>             <[hidden email] <mailto:[hidden email]>>:
>
>                 On Mon, Jun 19, 2017 at 4:49 PM, Italo Maia
>                 <[hidden email] <mailto:[hidden email]>>
>                 wrote:
>                 > (1) '5' + 5 gives you an 10.0 in the interactive
>                 console. Isn't this a
>                 > weakly typed language behavior?
>                 > (2) '5' + 5 > 10.0, string plus integer equals
>                 float. If an error was throw
>                 > here, it would be easier to understand than the
>                 given behavior.
>
>                 (1) In this case, it's a strongly-typed behavior. It's
>                 not treating
>                 strings and numbers as interchangeable; it's an
>                 explicitly documented
>                 behavior of the + operator, and there's a separate
>                 concatenation
>                 operator that has different semantics (number ..
>                 number -> string).
>                 This isn't like PHP where strings that look like
>                 numbers effectively
>                 ARE numbers and all sorts of bizarre things can happen
>                 with them. It's
>                 more like how C++ tries to find a type conversion to a
>                 function that
>                 doesn't directly support the types you used.
>
>                 (2) No, string plus number equals number, which can
>                 compare to another
>                 number. Lua does not have a distinct integer type; it
>                 didn't have an
>                 integer type _at all_ until 5.3 and that's a subtype
>                 with well-defined
>                 conversion rules (it coerces to a floating-point
>                 number very readily).
>
>                 /s/ Adam
>
>
>
>
>             --
>             "A arrogância é a arma dos fracos."
>
>             ===========================
>             Me. Italo Moreira Campelo Maia
>             Co-fundador do Grupo de Usuários Python do Ceará
>             Secretário ForHacker (fb.com/ForHackerSpace
>             <http://fb.com/ForHackerSpace>)
>             Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
>             -----------------------------------------------------
>             Meu Livro <http://bit.ly/flask-amazon>, Site
>             <http://www.italomaia.com/>, Blog
>             <http://eusouolobomau.blogspot.com/>
>             ===========================
>
>
>
>
>     --
>     "A arrogância é a arma dos fracos."
>
>     ===========================
>     Me. Italo Moreira Campelo Maia
>     Co-fundador do Grupo de Usuários Python do Ceará
>     Secretário ForHacker (fb.com/ForHackerSpace
>     <http://fb.com/ForHackerSpace>)
>     Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
>     -----------------------------------------------------
>     Meu Livro <http://bit.ly/flask-amazon>, Site
>     <http://www.italomaia.com/>, Blog <http://eusouolobomau.blogspot.com/>
>     ===========================
>
>
>
>
> --
> "A arrogância é a arma dos fracos."
>
> ===========================
> Me. Italo Moreira Campelo Maia
> Co-fundador do Grupo de Usuários Python do Ceará
> Secretário ForHacker (fb.com/ForHackerSpace
> <http://fb.com/ForHackerSpace>)
> Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
> -----------------------------------------------------
> Meu Livro <http://bit.ly/flask-amazon>, Site
> <http://www.italomaia.com/>, Blog <http://eusouolobomau.blogspot.com/>
> ===========================

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.


Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Coda Highland
In reply to this post by Italo Maia
On Mon, Jun 19, 2017 at 6:04 PM, Italo Maia <[hidden email]> wrote:
> Ok ... then, could someone provide an example of a weakly typed language? If
> there is no problem to operate on different types because the operation is
> defined, I'm quite unsure of what could be weakly typed.

PHP is the classic example. In PHP, a string that looks like a number
can have very strange behaviors. For example, 123 == "123foo" because
it coerces the string to a number before comparison. Likewise, "1e3"
== "1000". (Oddly, "123" != "123foo", so it's a little inconsistent.)

C is also a weakly typed language, but because it's also a STATICALLY
typed language the weakness is a little bit less risky. But you can
cast between all pointers freely, so the difference between a string
and a struct is really just a matter of how you choose to look at it.

C++ is somewhat stronger in its typing, because polymorphic data types
carry their own type information with them -- that is, the values
themselves know what their type is, not just because of how you choose
to access them. C++ will LET you violate that but it makes you
intentionally have to try.

Lua is stronger still, because ALL values have their types baked into
them, and it doesn't matter how you go at it, a number is a number, a
string is a string, and a table is a table, and the coercions don't
just treat the same value differently, they create a NEW value of the
new type.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

Sean Conner
In reply to this post by Italo Maia
It was thus said that the Great Italo Maia once stated:
> Ok ... then, could someone provide an example of a weakly typed language?

  K&R C (or C prior to the ANSI C Standard of 1989).  For example, in file
A:

        double foo(a,b)
        double a;
        double b;
        {
          return a + b;
        }

and in file B:

        bar()
        {
          return foo(3 + 4);
        }

Without a declaration, foo() defaults to returning an integer, so you might
be surprised when bar() returns 16 instead of 7 [1].  Even fixing it:

        extern double foo();
        double bar()
        {
          return foo(3+4);
        }

is problematic because the parameters are still passed in as integers, not
doubles (and here, the result is 0 [1]).

  BCPL, the predecessor to C, is even worse---*everything* is treated as an
unsigned integer and a "pointer" is just an index into a large integer array
called "memory" [2].  You still had structures though, which makes BCPL skip
the "typeless" moniker.

  Certain assemblers could be considered "weakly typed," like Microsoft's
MASM.  There, if you do:

        val dw 5 ; assign a 16 bits to the value 5
                push [val] ; push the quantity at val onto the stack

MASM knows to generate a 16-bit push because of the 'dw' designation.  If
you change it do:

        val dq 5
                push [val]

it would know to use a 32-bit push instruction.  Not all assemblers will do
this.

> If there is no problem to operate on different types because the operation
> is defined, I'm quite unsure of what could be weakly typed.

  In assembly, there are different instructions that operate on different
sized data:

                add al,5
                add ax,5
                add eax,5
                add rax,5
                movss xmm1,5
                addss xmm0,xmm1

but it's up to the programmer (or programmer and assembler) to pick the
right instruction.

  -spc

[1] At least, on my x86 32-bit system.  Your milage may vary.

[2] On the Amiga, the file system was written in BCPL, and a BCPL
        "pointer" was really an index into a 32-bit integer array---to get
        an address, you had to multiply the BCPL pointer by 4.

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

nobody
In reply to this post by Italo Maia
On 2017-06-20 01:04, Italo Maia wrote:
> Ok ... then, could someone provide an example of a weakly typed
> language? If there is no problem to operate on different types
> because the operation is defined, I'm quite unsure of what could be
> weakly typed.

C is weakly typed: `int main(void) { return *((int*)0); }` escapes from
the type system and hard-crashes the program, and it compiles with zero
warnings under `gcc -Wall -Wextra -pedantic`.

(`clang -Weverything` complains that I should have said `volatile int*`.
Adding that gives a warning-free compilation.  At -Weverything.  So as
far as C is concerned, that crashing one-liner is top quality code!)

-- nobody

Reply | Threaded
Open this post in threaded view
|

Re: Does Lua have a Roadmap?

steve donovan
In reply to this post by Coda Highland
On Mon, Jun 19, 2017 at 10:35 PM, Coda Highland <[hidden email]> wrote:
> (1) Lua is already strongly typed. It just has a very small list of
> recognized types, and one of those types is "table".

It could be argued that Python tends to be more strongly-typed, since
we have the happy habit of passing plain tables with implicit
(hopefully documented) structure, rather than a _distinct_ type.  So
API contracts tend to be looser.

> (2) Stronger typing than this would not simplify the language
> whatsoever. It would require a mechanism by which user-defined types
> can be added as well as mechanisms by which these types can be
> identified, manipulated, and instantiated.

We do have conventions, although as the late great Grace Hopper said,
"The wonderful thing about standards is that there's so many to choose
from".

We cannot however do things like define our own strings (the so-called
'virtualization' problem)

12