Some ATS code for Book "Getting Started with Arduino"

It looks pretty neat :slight_smile:

I make a minor suggestion:

When using $UN.cast, it is helpful if you can provide a type argument.

For instance,

$UN.cast{int}(xyz), $UN.cast{double}(xyz), $UN.cast{List0(int)}(xyz), etc.

Otherwise, it can be difficult for the reader to figure out the type of the
result after
casting.On Wed, Apr 22, 2015 at 8:49 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:

Hi all,

I wrote some ATS code to convert sample code of Book ā€œGetting Started
with Arduinoā€.

  • Example 01: Blinking LED

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/01_blink/DATS/main.dats

  • Example 02: Turn on LED while the button is pressed

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/02_button_press/DATS/main.dats

  • Example 03C: Turn on LED when the button is pressed

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/03_de_bouncing/DATS/main.dats

  • Example 04: Fade an LED in and out like on a sleeping Apple computer

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/04_pwm/DATS/main.dats

  • Example 05: Turn on LED when the button is pressed. Brightness changes

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/05_pwm_button/DATS/main.dats

  • Example 06A: Blink LED at a rate specified by the value of the
    analogue input

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/06a_analoginput_blink/DATS/main.dats

  • Example 06B: Set the brightness of LED to a brightness specified by
    the value of the analogue input

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/06b_analoginput_pwm/DATS/main.dats

  • Example 07: Send to the computer the values read from analogue input 0

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/07_analoginput_serial/DATS/main.dats

I think the ATS code is more smart than the original C language code. :slight_smile:

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

–
You received this message because you are subscribed to the Google Groups
ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAEvX6dkiPM2LcfGzVumRJ-3%2Bj%3DuSGHMxfbXtVSKOiBJFTna7ZQ%40mail.gmail.com
.

Yes, Java does not allow it, which I find to be very annoying.
That is why we urgently need atscc2java :)On Thursday, April 23, 2015 at 1:35:34 PM UTC-4, Brandon Barker wrote:

On Thu, Apr 23, 2015 at 1:09 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

On Thursday, April 23, 2015 at 12:26:18 PM UTC-4, Raoul Duke wrote:

Well, this can be a feature as well :slight_smile:
Imagine the following scenario:
#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#
A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.

My knee jerk reaction is to disagree and still think it must be a
compile time error.

Well, the current handling of the issue is consistent with the principle
of lexical scoping. I assume that you have no objection to the legality
of the following code:

val x = 1
val x = 2

Then it is only natural to handle the following declarations similarly:

fun foo : int → int
fun foo : (int, int) → int

Yes, it is most likely that a mistake is made if some writes this kind of
stuff. But …

Let us imagine that the code is automatically generated (instead of being
written
manually).

If it were stated in the C standard that a vacuous label is illegal, then
compiling into
C would have been a lot more difficult.

If I understand correctly, Kotlin and Scala and others all use the
convention that val is immutable and var is mutable, so that

val x = 1
val x = 2

would not compile. Additionally, there seem to be translators going from
Java to both of these languages that aren’t flawless but work fairly well -
still, I take your word for it, just wanted to point this out.

Now let us dream contexts where I might cave in. E.g. if there’s no
such thing as namespaces, then things are so bad already that we are
forced to do / allow otherwise insanely bad habits, I guess. :frowning:

BTW is there an ATS lang spec somewhere? I could not find it in 2
minutes of looking on the web site. I’m a nerd and want that stuff
readily available. :slight_smile:

–
You received this message because you are subscribed to the Google Groups
ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com?utm_medium=email&utm_source=footer
.

–
Brandon Barker
brand...@gmail.com <javascript:>

I am a big fan of shadowing. For instance,

fun sum (xs: List(int)): int
case+ xs of
| list_nil () => 0
| list_cons (x, xs) => x + sum(xs)

Yes, I can always write:

| list_cons (x, xs2) => x + sum(xs2)

But I consider it to be inferior. Shdowing xs prevents it from being
used by mistake.On Thursday, April 23, 2015 at 1:45:34 PM UTC-4, Raoul Duke wrote:

val x = 1
val x = 2

If those are in the same scope then they should at least generate a
warning. Personally I want those to be an outright error. Ditto having
a local var that is the same name as a function input name. Etc.
Shadowing is long-term bad. Even scoped shadowing is something I worry
about, quite seriously, although I don’t currently say we should
disallow it.

pseudocode:

{ val x = 1 { val x = 2; print(x); } }

is ethically very different than

{ val x = 1; val x = 2; print(x); }

in my mind.

Even if those are ā€œvarsā€ instead of ā€œvalsā€ per Scala et. al., I
generally consider shadowing to be badness/madness.

$0.02

Instead of treating a pin as a number, we can treat it as a linear resource:

absvtype pin(int(n), int(i/o))

fun pin_take(int(n)): pin(n,~1) // get the resource
fun pin_return(pin(n, i)): void // return the resource // ~1: uninitialized

fun pinMode(!pin(n, i) >> !pin(n, j), mode: int(j)): void // for INPUT or
OUTPUT

fun digitalRead (!pin(n, 0)): int // [0] for INPUT
fun digitalWrite (!pin(n, 1), data: int): void // [1] for OUTPUT

This probably looks too heavy handed. My original intent is to use the
interface to
teach linear types.On Thursday, April 23, 2015 at 10:18:20 AM UTC-4, Kiwamu Okabe wrote:

Hi Brandon,

On Thu, Apr 23, 2015 at 10:46 PM, Brandon Barker <brand...@gmail.com <javascript:>> wrote:

I think the idea is that you will get a typechecking error if you now
try to use digitalRead2 on a write-only pin or vice versa for
digitalWrite2?

Yes. I think I understand it.
However I can’t imagine the application code…

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

Well, this can be a feature as well :slight_smile:
Imagine the following scenario:
#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#
A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.

My knee jerk reaction is to disagree and still think it must be a
compile time error.

Well, the current handling of the issue is consistent with the principle
of lexical scoping. I assume that you have no objection to the legality
of the following code:

val x = 1
val x = 2

Then it is only natural to handle the following declarations similarly:

fun foo : int → int
fun foo : (int, int) → int

Yes, it is most likely that a mistake is made if some writes this kind of
stuff. But …

Let us imagine that the code is automatically generated (instead of being
written
manually).

If it were stated in the C standard that a vacuous label is illegal, then
compiling into
C would have been a lot more difficult.

But yes, I am not immediately sure how to make this work.On Thu, Apr 23, 2015 at 9:46 AM, Brandon Barker brandon...@gmail.com wrote:

I think the idea is that you will get a typechecking error if you now
try to use digitalRead2 on a write-only pin or vice versa for
digitalWrite2?

On Thu, Apr 23, 2015 at 7:28 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:

Hi Hongwei,

On Wed, Apr 22, 2015 at 10:20 PM, gmhwxi gmh...@gmail.com wrote:

Clearly, digitalRead should only be called on an output pin.
So you may introduce an abstract type:

absvtype pin(int) // linear type // 0/1: input/output

Then do:

fun digitalRead2 (!pin(OUTPUT)): int = ā€œmac#digitalReadā€
fun digitalWrite2 (!pint(INPUT), int): void = ā€œmac#digitalWriteā€

Sorry, not make sense.
Could you show some application code using the function
ā€œdigitalRead2ā€ or ā€œdigitalWrite2ā€?

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

–
You received this message because you are subscribed to the Google Groups ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAEvX6dm3DhjkmMd9%3Dr143bJNPU6ErgDcA8ASyq32z2TV9tdx%2Bw%40mail.gmail.com.

–
Brandon Barker
brandon...@gmail.com

Brandon Barker
brandon...@gmail.com

You had:
fun delay(ms: ulint): void = ā€œmac#ā€
fun delay(us: uint): void = ā€œmac#ā€
The second one overwrites the first one.

why/isn’t that a compile time error, or warning at least?

You had:

fun delay(ms: ulint): void = ā€œmac#ā€ fun delay(us: uint): void = ā€œmac#ā€

The second one overwrites the first one.

Try something like:

fun delay_uint (uint): void = ā€œmac#ā€
fun delay_ulint (ulint): void = ā€œmac#ā€
overload delay with delay_uint
overload delay with delay_ulintOn Thursday, April 23, 2015 at 7:21:08 AM UTC-4, Kiwamu Okabe wrote:

Hi Hongwei,

On Wed, Apr 22, 2015 at 9:59 PM, Hongwei Xi <gmh...@gmail.com <javascript:>> wrote:

When using $UN.cast, it is helpful if you can provide a type argument.

For instance,

$UN.cast{int}(xyz), $UN.cast{double}(xyz), $UN.cast{List0(int)}(xyz),
etc.

Thank’s. It fixed my headache on casting.

Specify cast type Ā· fpiot/arduino-ats@61777c2 Ā· GitHub

… However, following change will occur type error… Why?

$ git diff | cat
diff --git a/demo/06a_analoginput_blink/DATS/main.dats
b/demo/06a_analoginput_blink/DATS/main.dats
index 2ac2d57…74e703f 100644
— a/demo/06a_analoginput_blink/DATS/main.dats
+++ b/demo/06a_analoginput_blink/DATS/main.dats
@@ -11,7 +11,7 @@ implement main () = {
fun loop () = {
val w = analogRead (SENSOR)
val () = digitalWrite (LED, HIGH)

  • val () = delay ($UN.cast w)
  • val () = delay ($UN.cast{ulint}(w))
    val () = digitalWrite (LED, LOW)
    val () = delay ($UN.cast w)
    val () = loop ()
    $ make
    –ship–
    patsopt -o DATS/main_dats.c.tmp -d DATS/main.dats
    /home/kiwamu/src/arduino-ats/demo/06a_analoginput_blink/DATS/main.dats:
    314(line=14, offs=21) – 331(line=14, offs=38): warning(3): the
    constraint [S2Eeqeq(S2Eextkind(atstype_ulint); S2Eextkind(atstype_uint))] cannot be translated into a form accepted
    by the constraint solver.
    /home/kiwamu/src/arduino-ats/demo/06a_analoginput_blink/DATS/main.dats:
    314(line=14, offs=21) – 331(line=14, offs=38): error(3): unsolved
    constraint: C3NSTRprop(main; S2Eeqeq(S2Eextkind(atstype_ulint);
    S2Eextkind(atstype_uint)))
    typechecking has failed: there are some unsolved constraints: please
    inspect the above reported error message(s) for information.
    exit(ATS): uncaught exception:
    _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)

…/…/Makefile.common:61: recipe for target ā€˜DATS/main_dats.c’ failed

The ā€œdelayā€ function is defined as following.

fun delay(ms: ulint): void = ā€œmac#ā€

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

Let us take a look at the following code:

implement main () = {
fun loop () = {
val b = digitalRead (BUTTON)
val () = digitalWrite (LED, b)
val () = loop ()
}
val () = pinMode (LED, OUTPUT)
val () = pinMode (BUTTON, INPUT)
val () = loop ()
}

Clearly, digitalRead should only be called on an output pin.
So you may introduce an abstract type:

absvtype pin(int) // linear type // 0/1: input/output

Then do:

fun digitalRead2 (!pin(OUTPUT)): int = ā€œmac#digitalReadā€
fun digitalWrite2 (!pint(INPUT), int): void = ā€œmac#digitalWriteā€

It should now be clear where I am headed :slight_smile:

The problem is that Arduino programs tend to be simple and small.
There is not a lot of motivation for using advanced types in ATS.On Wednesday, April 22, 2015 at 8:50:08 AM UTC-4, Kiwamu Okabe wrote:

Hi all,

I wrote some ATS code to convert sample code of Book ā€œGetting Started
with Arduinoā€.

  • Example 01: Blinking LED

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/01_blink/DATS/main.dats

  • Example 02: Turn on LED while the button is pressed

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/02_button_press/DATS/main.dats

  • Example 03C: Turn on LED when the button is pressed

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/03_de_bouncing/DATS/main.dats

  • Example 04: Fade an LED in and out like on a sleeping Apple computer

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/04_pwm/DATS/main.dats

  • Example 05: Turn on LED when the button is pressed. Brightness changes

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/05_pwm_button/DATS/main.dats

  • Example 06A: Blink LED at a rate specified by the value of the
    analogue input

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/06a_analoginput_blink/DATS/main.dats

  • Example 06B: Set the brightness of LED to a brightness specified by
    the value of the analogue input

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/06b_analoginput_pwm/DATS/main.dats

  • Example 07: Send to the computer the values read from analogue input 0

https://github.com/fpiot/arduino-ats/blob/feature/hongwei-style-io/demo/07_analoginput_serial/DATS/main.dats

I think the ATS code is more smart than the original C language code. :slight_smile:

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

But I consider it to be inferior. Shdowing xs prevents it from being
used by mistake.

I see what you mean.

As in all such things, damned if you do & damned if you don’t. With
shadowing we can have mistakes. Without shadowing we can have
mistakes. I do not know enough to know when to choose which, taking in
to consideration the full context every time: host syntax, target
syntax, etc.

And I do find Erlang’s single assignment to be noisy, but on the other
hand I believe I’ve see enough damage from not doing that kind of
thing to respect Erlang’s choice (though see e.g. Reia discussions).

Still, I would rather somebody (someday somewhere) try to see what
could be done instead of allowing shadowing like in your example. If
we don’t allow shadowing what could be done to manage / avoid /
prevent / detect any mistakes where we use xs instead of xs2? A
usability question.

Ah yes, thanks for the reminder (as I attempt to do functional programming
to the extent possible in Java). I do seem to recall Kotlin had to roll
their own TCO, but didn’t find the details.On Thu, Apr 23, 2015 at 6:13 PM, gmhwxi gmh...@gmail.com wrote:

By the way, Java 8 does not do tail-call optimization.
Very annoying.

On Thursday, April 23, 2015 at 2:16:52 PM UTC-4, gmhwxi wrote:

Yes, Java does not allow it, which I find to be very annoying.
That is why we urgently need atscc2java :slight_smile:

On Thursday, April 23, 2015 at 1:35:34 PM UTC-4, Brandon Barker wrote:

On Thu, Apr 23, 2015 at 1:09 PM, gmhwxi gmh...@gmail.com wrote:

On Thursday, April 23, 2015 at 12:26:18 PM UTC-4, Raoul Duke wrote:

Well, this can be a feature as well :slight_smile:
Imagine the following scenario:
#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#
A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.

My knee jerk reaction is to disagree and still think it must be a
compile time error.

Well, the current handling of the issue is consistent with the principle
of lexical scoping. I assume that you have no objection to the legality
of the following code:

val x = 1
val x = 2

Then it is only natural to handle the following declarations similarly:

fun foo : int → int
fun foo : (int, int) → int

Yes, it is most likely that a mistake is made if some writes this kind
of stuff. But …

Let us imagine that the code is automatically generated (instead of
being written
manually).

If it were stated in the C standard that a vacuous label is illegal,
then compiling into
C would have been a lot more difficult.

If I understand correctly, Kotlin and Scala and others all use the
convention that val is immutable and var is mutable, so that

val x = 1
val x = 2

would not compile. Additionally, there seem to be translators going from
Java to both of these languages that aren’t flawless but work fairly well -
still, I take your word for it, just wanted to point this out.

Now let us dream contexts where I might cave in. E.g. if there’s no
such thing as namespaces, then things are so bad already that we are
forced to do / allow otherwise insanely bad habits, I guess. :frowning:

BTW is there an ATS lang spec somewhere? I could not find it in 2
minutes of looking on the web site. I’m a nerd and want that stuff
readily available. :slight_smile:

–
You received this message because you are subscribed to the Google
Groups ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com?utm_medium=email&utm_source=footer
.

–
Brandon Barker
brand...@gmail.com

–
You received this message because you are subscribed to the Google Groups
ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/51033971-3517-4c83-9a6a-3f7dd1c5e71e%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/51033971-3517-4c83-9a6a-3f7dd1c5e71e%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

By the way, Java 8 does not do tail-call optimization.
Very annoying.On Thursday, April 23, 2015 at 2:16:52 PM UTC-4, gmhwxi wrote:

Yes, Java does not allow it, which I find to be very annoying.
That is why we urgently need atscc2java :slight_smile:

On Thursday, April 23, 2015 at 1:35:34 PM UTC-4, Brandon Barker wrote:

On Thu, Apr 23, 2015 at 1:09 PM, gmhwxi gmh...@gmail.com wrote:

On Thursday, April 23, 2015 at 12:26:18 PM UTC-4, Raoul Duke wrote:

Well, this can be a feature as well :slight_smile:
Imagine the following scenario:
#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#
A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.

My knee jerk reaction is to disagree and still think it must be a
compile time error.

Well, the current handling of the issue is consistent with the principle
of lexical scoping. I assume that you have no objection to the legality
of the following code:

val x = 1
val x = 2

Then it is only natural to handle the following declarations similarly:

fun foo : int → int
fun foo : (int, int) → int

Yes, it is most likely that a mistake is made if some writes this kind
of stuff. But …

Let us imagine that the code is automatically generated (instead of
being written
manually).

If it were stated in the C standard that a vacuous label is illegal,
then compiling into
C would have been a lot more difficult.

If I understand correctly, Kotlin and Scala and others all use the
convention that val is immutable and var is mutable, so that

val x = 1
val x = 2

would not compile. Additionally, there seem to be translators going from
Java to both of these languages that aren’t flawless but work fairly well -
still, I take your word for it, just wanted to point this out.

Now let us dream contexts where I might cave in. E.g. if there’s no
such thing as namespaces, then things are so bad already that we are
forced to do / allow otherwise insanely bad habits, I guess. :frowning:

BTW is there an ATS lang spec somewhere? I could not find it in 2
minutes of looking on the web site. I’m a nerd and want that stuff
readily available. :slight_smile:

–
You received this message because you are subscribed to the Google
Groups ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com?utm_medium=email&utm_source=footer
.

–
Brandon Barker
brand...@gmail.com

Well, this can be a feature as well :slight_smile:
Imagine the following scenario:
#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#
A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.

My knee jerk reaction is to disagree and still think it must be a
compile time error.

Well, the current handling of the issue is consistent with the principle
of lexical scoping. I assume that you have no objection to the legality
of the following code:

val x = 1
val x = 2

Then it is only natural to handle the following declarations similarly:

fun foo : int → int
fun foo : (int, int) → int

Yes, it is most likely that a mistake is made if some writes this kind of
stuff. But …

Let us imagine that the code is automatically generated (instead of being
written
manually).

If it were stated in the C standard that a vacuous label is illegal, then
compiling into
C would have been a lot more difficult.

If I understand correctly, Kotlin and Scala and others all use the
convention that val is immutable and var is mutable, so that

val x = 1
val x = 2

would not compile. Additionally, there seem to be translators going from
Java to both of these languages that aren’t flawless but work fairly well -
still, I take your word for it, just wanted to point this out.

Now let us dream contexts where I might cave in. E.g. if there’s no
such thing as namespaces, then things are so bad already that we are
forced to do / allow otherwise insanely bad habits, I guess. :frowning:

BTW is there an ATS lang spec somewhere? I could not find it in 2
minutes of looking on the web site. I’m a nerd and want that stuff
readily available. :slight_smile:

–
You received this message because you are subscribed to the Google Groups
ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/50784cf3-206e-4e21-8828-ebcf21d5e412%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

Well, this can be a feature as well :slight_smile:
Imagine the following scenario:
#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#
A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.

My knee jerk reaction is to disagree and still think it must be a
compile time error.

Now let us dream contexts where I might cave in. E.g. if there’s no
such thing as namespaces, then things are so bad already that we are
forced to do / allow otherwise insanely bad habits, I guess. :frowning:

BTW is there an ATS lang spec somewhere? I could not find it in 2
minutes of looking on the web site. I’m a nerd and want that stuff
readily available. :slight_smile:

I think the idea is that you will get a typechecking error if you now
try to use digitalRead2 on a write-only pin or vice versa for
digitalWrite2?On Thu, Apr 23, 2015 at 7:28 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:

Hi Hongwei,

On Wed, Apr 22, 2015 at 10:20 PM, gmhwxi gmh...@gmail.com wrote:

Clearly, digitalRead should only be called on an output pin.
So you may introduce an abstract type:

absvtype pin(int) // linear type // 0/1: input/output

Then do:

fun digitalRead2 (!pin(OUTPUT)): int = ā€œmac#digitalReadā€
fun digitalWrite2 (!pint(INPUT), int): void = ā€œmac#digitalWriteā€

Sorry, not make sense.
Could you show some application code using the function
ā€œdigitalRead2ā€ or ā€œdigitalWrite2ā€?

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

–
You received this message because you are subscribed to the Google Groups ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAEvX6dm3DhjkmMd9%3Dr143bJNPU6ErgDcA8ASyq32z2TV9tdx%2Bw%40mail.gmail.com.

Brandon Barker
brandon...@gmail.com

scala too

Well, this can be a feature as well :slight_smile:

Imagine the following scenario:

#include ā€œfoo.satsā€ // [delay] is already declared here
fun delay (…): void = "mac#

A warning sounds reasonable. As I see it, the right place for
handling this is in some kind of IDE.On Thu, Apr 23, 2015 at 11:59 AM, Raoul Duke rao...@gmail.com wrote:

You had:
fun delay(ms: ulint): void = ā€œmac#ā€
fun delay(us: uint): void = ā€œmac#ā€
The second one overwrites the first one.

why/isn’t that a compile time error, or warning at least?

–
You received this message because you are subscribed to the Google Groups
ā€œats-lang-usersā€ group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb6BRhz0Fk1uO4iZ1Xr5i8ddn-Ey6hgSrxxh1F6TmTK5jQ%40mail.gmail.com
.

val x = 1
val x = 2

If those are in the same scope then they should at least generate a
warning. Personally I want those to be an outright error. Ditto having
a local var that is the same name as a function input name. Etc.
Shadowing is long-term bad. Even scoped shadowing is something I worry
about, quite seriously, although I don’t currently say we should
disallow it.

pseudocode:

{ val x = 1 { val x = 2; print(x); } }

is ethically very different than

{ val x = 1; val x = 2; print(x); }

in my mind.

Even if those are ā€œvarsā€ instead of ā€œvalsā€ per Scala et. al., I
generally consider shadowing to be badness/madness.

$0.02