Discuss Scratch

Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Sigton wrote:

-Io- wrote:

Can I see the current code for parse()? The one on Github has syntax errors.
This one shouldn't have the syntax errors.

Sigton
Wouldn't that fail because the functions are defined after you reference them in the object?
Ohhhhh you accidently gave me the answer to the problem! (I hope)
It doesn't fail, but because I'm referencing before assignement then the object is just being filled with undefined because it is undefined. Thanks xD

Sigton

EDIT: Yes that was the problem, thanks for your help

Last edited by Sigton (Nov. 28, 2016 17:57:51)

-Io-
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

-Io- wrote:

Can I see the current code for parse()? The one on Github has syntax errors.
This one shouldn't have the syntax errors.

Sigton
Ohhhh, the problem is in how you're defining your functions.

Normal function statements get hoisted: (you can always access them no matter where you define them)
hoisted(); // logs "foo"
function hoisted() {
  console.log("foo");
}
Others do not:
notHoisted(); // TypeError: notHoisted is not a function
var notHoisted = function() {
   console.log("bar");
};

You have to either change sum, sub, mult and div to use a function statement, or declare them before you declare “functions”.

EDIT: dangit ninja'd

Last edited by -Io- (Nov. 28, 2016 17:59:58)

Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sorry, first time I've really used JS

Sigton
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Great, the js interpreter now works perfectly ;D

Sigton
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

Great, the js interpreter now works perfectly ;D

Sigton
String support has been added, I'll work on arrays tomorrow.

Sigton
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

Sigton wrote:

Great, the js interpreter now works perfectly ;D

Sigton
String support has been added, I'll work on arrays tomorrow.

Sigton
With all of the implicit opening/closing (?) quote stuff done - and backslash escaping?
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Sigton wrote:

Sigton wrote:

Great, the js interpreter now works perfectly ;D

Sigton
String support has been added, I'll work on arrays tomorrow.

Sigton
With all of the implicit opening/closing (?) quote stuff done - and backslash escaping?
Implicit opening will take a minute, and I haven't got around to backslash escaping in either language

Sigton
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

jokebookservice1 wrote:

Sigton wrote:

Sigton wrote:

Great, the js interpreter now works perfectly ;D

Sigton
String support has been added, I'll work on arrays tomorrow.

Sigton
With all of the implicit opening/closing (?) quote stuff done - and backslash escaping?
Implicit opening will take a minute, and I haven't got around to backslash escaping in either language

Sigton
"\\" //returns "\" in js .-.

Saiid
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

Sigton wrote:

jokebookservice1 wrote:

Sigton wrote:

Sigton wrote:

Great, the js interpreter now works perfectly ;D

Sigton
String support has been added, I'll work on arrays tomorrow.

Sigton
With all of the implicit opening/closing (?) quote stuff done - and backslash escaping?
Implicit opening will take a minute, and I haven't got around to backslash escaping in either language

Sigton
"\\" //returns "\" in js .-.

Saiid
No, I know how to backslash escape in both Python and JavaScript, just haven't added it to the Python or JS version of pgs yet

Sigton
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Variables are sorted, having a little trouble with pushing to arrays though. It'll be fixed shortly hopefully…

Sigton
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Okay, really confused.
var a = {
  "a":0,
  "b":0,
  "c":0
}
1 in a
// returns true
Is this some js quirk I don't know about?

Sigton
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

Okay, really confused.
var a = {
  "a":0,
  "b":0,
  "c":0
}
1 in a
// returns true
Is this some js quirk I don't know about?

Sigton
Not sure what interpreter you used, but my console returns that as false.
On a different note, I found out that you can make an if/else statement with no brackets
if (true) console.log(true); else console.log(false);
and, it only supports a single action for both, so
if(true)console.log("Hello");else console.log("hello");console.log("world!")
prints “Hello” to the console, then prints “world!”

Saiid
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

Not sure what interpreter you used, but my console returns that as false.

Saiid
I tried again and it printed false.
Now I'm really, really confused xD

Sigton
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

Saiid wrote:

Not sure what interpreter you used, but my console returns that as false.

Saiid
I tried again and it printed false.
Now I'm really, really confused xD

Sigton
xD

Saiid
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

It appears that using an if/else statement without brackets also works vertically -
if (true)
console.log(true);
else
console.log(!true);
console.log("Hello")
returns the console as
true
Hello

Saiid
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

It appears that using an if/else statement without brackets also works vertically -
if (true)
console.log(true);
else
console.log(!true);
console.log("Hello")
returns the console as
true
Hello

Saiid
Yes, because JS does not care about newlines; it just runs (if there is ambiguity it can be resolved with semicolons - but usually they are optional)
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Saiid wrote:

It appears that using an if/else statement without brackets also works vertically -
if (true)
console.log(true);
else
console.log(!true);
console.log("Hello")
returns the console as
true
Hello

Saiid
Yes, because JS does not care about newlines; it just runs (if there is ambiguity it can be resolved with semicolons - but usually they are optional)
ah

Saiid
Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

@Saiid
Please merge the PR's I've made, they fix bugs with the IDE and update the website to the latest version.

Sigton
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

@Saiid
Please merge the PR's I've made, they fix bugs with the IDE and update the website to the latest version.

Sigton
Just did. Also, I invited you as a collaborator with Admin level powers, since I trust you

Saiid
ScratchMan544
Scratcher
100+ posts

PigeonScript - a Golfing Language

Saiid wrote:

-snip-
On a different note, I found out that you can make an if/else statement with no brackets
if (true) console.log(true); else console.log(false);
and, it only supports a single action for both, so
if(true)console.log("Hello");else console.log("hello");console.log("world!")
prints “Hello” to the console, then prints “world!”

Saiid

Yeah. That's a quirk of the original C-like syntax. Control constructs only accept a single “statement”, but wrapping multiple statements in { } makes them be treated by the parser as a single statement. This also means you can have empty loops and things like this:

#include <stdio.h>
int /* another quirk of C-like syntax is that you can put comments almost anywhere. */ main() {
    // copies the input to the output
    for (char c; (c = getchar()) != EOF; putchar(c)); // this loop has no body, as the trailing semicolon is a single statement that has no effect.
}

Last edited by ScratchMan544 (Dec. 1, 2016 01:40:39)

Powered by DjangoBB