YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

A weird thing in the reference manual
Kelvin
#1 Posted : Thursday, April 8, 2021 6:41:55 AM(UTC)
Rank: Advanced Member

Groups: Registered, Moderator
Joined: 3/26/2015(UTC)
Posts: 61
Man
Location: Georgia

Thanks: 3 times
Was thanked: 0 time(s) in 0 post(s)
I've noticed that the reference manual has a ton of statements along these lines as example code:
Code:

initz := id [= exp][',' initz]
stat := 'local' initz

memberdecl := id '=' exp [';'] |    '[' exp ']' '=' exp [';'] |    functionstat | 'constructor' functionexp
stat:= 'class' derefexp ['extends' derefexp] '{'
    [memberdecl]
'}'

funcname := id ['::' id]
stat:= 'function' id ['::' id]+ '(' args ')'[':' '(' args ')'] stat

I remember being very perplexed by these when I first started learning Squirrel, and I have to ask, why are they here? They look nothing like what the actual language looks like.
absence
#2 Posted : Monday, April 12, 2021 10:56:48 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/23/2014(UTC)
Posts: 142
Man
Location: Northern Germany & Lincolnshire, U.K.

Thanks: 2 times
Was thanked: 10 time(s) in 10 post(s)
Because they're a Syntax defining "language". If you like to dig in, start reading for example about YACC, formal grammar and synax definitions
Kelvin
#3 Posted : Sunday, April 25, 2021 7:36:13 AM(UTC)
Rank: Advanced Member

Groups: Registered, Moderator
Joined: 3/26/2015(UTC)
Posts: 61
Man
Location: Georgia

Thanks: 3 times
Was thanked: 0 time(s) in 0 post(s)
OK, but why is it there? It feels weird that to read an example of how to write in a language, I have to go learn yet another language. Why not just write the examples in Squirrel?
absence
#4 Posted : Tuesday, May 11, 2021 8:45:28 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/23/2014(UTC)
Posts: 142
Man
Location: Northern Germany & Lincolnshire, U.K.

Thanks: 2 times
Was thanked: 10 time(s) in 10 post(s)
Well, because it's a definition, not an example. You'd need lots of examples to replace a definition, think of "expr" (expression). An expression can be a lot, it may contain operators, paranthesis and what not.
So the definition of

local id := expr

ranges from the simple example
local a = true

via

local somerandomvariablename = { "foobar":[0,1,2,3] }

to

local WhatTheHeckIsHetThinkingAboutVariableNames = (sin(5)*("0.4565".tofloat())/somefunction(this)?1:anotherweirdfunc.bindenv(a).call({a=a,"b":"I'm a nutter",[null]},true) || (this()<-@"haha,hope that 'this' is no class!")

or even stranger expressions. You get the idea I think :)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.035 seconds.