Comments (2)
TLDR: lci doesn't seem to handle Bukkit inheritance quite right. There's a possible workaround (see below).
Explanation
Interesting behavior indeed. I've dug into this a bit and here's what I've found.
I believe lci was patterned after the Lolcode 1.3 proposal for Bukkits, so a rough explanation for how this should work can be found in the archived proposal.
Inheritance / Prototyping
To create an object based upon an existing object:
I HAS A <object> ITZ LIEK A <parent>
Behavior of this sort of inheritance is described further below.
To define inheritance using alternate syntax, do the following.
O HAI IM <object> [IM LIEK <parent>] <code block> KTHX
Inheritance implies a few things, one of which is inheritance of slots (described below). Another thing inheritance does is automatically > create a “parent” slot on the new object. The “parent” slot refers to the object that this object was inherited from, or its prototype. > The parent slot is treated specially by the Bukkit.
...
Assigning a variable within the object first searches for it within the current object. If it has been declared within the current object, then it is set. If that fails, it attempts to access it within the parent object. Search continues in up the chain of parents. If the variable name is found up the inheritance chain, then that variable is declared and created within the current object (where the search started), and the value is set. If the variable search fails and the variable was never previously assigned, then it's a declaration error.
Looking at your example program, it seems that lci is not completely following that last paragraph. It says that "If the variable name is found up the inheritance chain, then that variable is declared and created within the current object". Currently, if the variable name is found up the inheritance chain, then the variable is changed within the parent object.
The code responsible for the assignment is in the updateScopeValue() function. The interpreter shares the same logic for updating nested scopes and Bukkits. Currently, the logic is correctly written for scopes but not for Bukkits. We may need to add Bukkit-specific logic to the function to handle updating inherited fields.
Workaround
In the meantime, the tests in 1.3-Tests/12-Arrays/13-Inheritance/2-Assignment
demonstrate a method that might be able to help with your use case. If you want to override the value of a parent's field, you can use the following syntax to set it on the child:
I HAS A parent ITZ A BUKKIT
parent HAS A foo ITZ "bar"
I HAS A child ITZ LIEK A parent
child HAS A foo ITZ "baz"
I HAS A otherChild ITZ LIEK A parent
VISIBLE SMOOSH "Parent:: " AN parent'Z foo MKAY
VISIBLE SMOOSH "Child:: " AN child'Z foo MKAY
VISIBLE SMOOSH "Other child:: " AN otherChild'Z foo MKAY
from lci.
Thank you for the explanation! That makes sense to me :)
My usecase was to read input into an object with different fields, and then making a copy of that object so that I could have an unmodified copy and a working copy.
Anyway, I have managed to copy without LIEK
and finished the adventofcode task I was working on, so I don't need further assistance.
Enjoy the rest of your weekend!
from lci.
Related Issues (20)
- NUMBAR doesn't always work with line continuation
- EOL doesn't replace MKAY when calling a variadic function
- Function can read and modify variables in outside scope
- Python 2 is EOL in 3 months
- BTW may not appear on the same line as TLDR
- Is lolcode dead?
- Suggestion: PIPE library to allow execution of commands in LOLCODE
- 'future' branch interpreter array errors HOT 2
- Windows Standalone Version
- Loops always create a loop-scope variable and initialize it to 0
- Does not work on replit.
- Does this allows to embed into software as a script language? HOT 1
- LOLCODE for Windows 10 HOT 1
- test fail with Python 3
- Error Installing: There was a Make error - Readline.h HOT 4
- CMake ERROR HOT 1
- Functions of NOOB very limited
- Out of Bounds Read and Null Pointer Dereference in LCI Version 0.10.5
- Link to spec? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lci.