ArkScript v4.0.0 #579
SuperFola
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Changes for you, as a user
(macro name value)and(macro name (foo bar ...args) body)instead of!{name value}and!{name (foo bar ...args) body}quotekeyword got removed. You can emulate it with a macro:(macro quote (value) (fun () value))(it wasn't really a Lispquotein the first place...)(import "path/to/file.ark")to java like imports (the root is deduced from the main script emplacement):(import path.to.file :foo :bar)arkscript -f myfile.arkdictdatatype: https://arkscript-lang.dev/docs/std/dict/For more information, check the language documentation!
Technical changelog
Added
fmtlib$reprmacro to get a string representation of a given nodearkscript -f|--formatVM::forceReloadPlugins, to be used by the REPL to force reload the plugins and be sure that their symbols are all definedhelp,save(save history to disk),history(print history),reset(reset vm and code) commands to the REPL>to:)typelist,concat,appendand friends to only push valid nodes (that produce a value)Ark::internal::Passto describe compiler passes: they all output an AST (parser, import solver, macro processor, and optimizer for now)-f(no-)importsolver,-f(no-)macroprocessorand-f(no-)optimizerto toggle on and off those compiler passesempty?as a macro when possibleandandorimplementation--checkto the formatter as an option: returns 0 if the code is correctly formatted, 1 otherwiseappend!,concat!andpop!MAKE_CLOSURE <page addr>instruction, generated in place of aLOAD_CONSTwhen a closure is made-fdump-irto dump the IR entities to a file named{file}.ark.ir(string:setAt string index char)(bound checked)(@= list|string index new_value),(@@= list|list<string> index1 index2 new_value|char)(bound checked)andandor@@to get elements in list of lists / list of stringsrandom, returning a random number between INT_MIN and INT_MAX, or in a custom range$as-isto paste a node inside a maro without evaluating it further; useful to stop recursive evaluation of nodes inside function macrosLOAD_SYMBOL_BY_INDEXinstruction, loading a local from the current scope by an index (0 being the last element added to the scope)STORE_FROM_INDEXandSET_VAL_FROM_INDEXinstructions for parity with the super instructions not using load by indexINCREMENT_BY_INDEXandDECREMENT_BY_INDEXinstructions for parity with the super instructions not using load by indexSTORE_TAIL_BY_INDEX,STORE_HEAD_BY_INDEX,SET_VAL_TAIL_BY_INDEX,SET_VAL_HEAD_BY_INDEXsuper instructions added for parity with the super instructions not using load by indexRESET_SCOPE_JUMPinstruction emitted at the end of a while loop to reset a scope so that we can create multiple variables and useLOAD_SYMBOL_BY_INDEXLT_CONST_JUMP_IF_FALSEandLT_SYM_JUMP_IF_FALSEto compare a symbol to a const and a symbol to a symbol (respectively), then jump to an address if false (useful for while loops that check a simple(< x n)condition)LT_CONST_JUMP_IF_TRUE, counterpart ofLT_CONST_JUMP_IF_FALSEGT_CONST_JUMP_IF_TRUE, counterpart ofLT_CONST_JUMP_IF_TRUEGT_CONST_JUMP_IF_FALSE, counterpart ofLT_CONST_JUMP_IF_FALSEGT_SYM_JUMP_IF_FALSE, counterpart ofLT_SYM_JUMP_IF_FALSECALL_SYMBOLsuper instruction to load and call a symbol in a single instructionGET_FIELD_FROM_SYMBOLandGET_FIELD_FROM_SYMBOL_INDEXsuper instructions to get a field from a closure and push it to the stackEQ_CONST_JUMP_IF_TRUEandEQ_SYM_INDEX_JUMP_IF_TRUEto compare a symbol to a const and a symbol to a symbol (respectively), then jump to an address if true (useful for conditions that check a simple(= x n)condition)NEQ_CONST_JUMP_IF_TRUEas a super instruction counterpart toEQ_CONST_JUMP_IF_TRUENEQ_SYM_JUMP_IF_FALSE, counterpart ofLT_SYM_JUMP_IF_FALSEfor inequalityAT_SYM_SYMandAT_SYM_INDEX_SYM_INDEXsuper instructions, to get an element from a list in a single instruction, avoiding 2 push and 2 popCHECK_TYPE_OFandCHECK_TYPE_OF_BY_INDEXsuper instructions, to check the type of variable against a constant in a single instructionINCREMENT_STOREandDECREMENT_STOREsuper instructions, to update a value in place when incrementing/decrementing it by a set amountAPPEND_IN_PLACE_SYMandAPPEND_IN_PLACE_SYM_INDEXsuper instructionsPUSH_RETURN_ADDRESSinstruction now replaces the VM auto push of IP/PPGET_CURRENT_PAGE_ADDRESSinstruction to push the current page address to the stackCALL_CURRENT_PAGEsuper instruction, calling the current page with a given number of arguments (avoid loading a page address on the stack, then popping it to perform the call)Dict, which can be created with(dict "key" "value" ...), and manipulated withdict:get,dict:add,dict:contains,dict:remove,dict:keysanddict:sizeSTORE_LENsuper instruction, to load a symbol by index and store its length (if it's a string or list) in a new variableAT_SYM_INDEX_CONSTsuper instruction, to load a value from a container using a constant as the indexChanged
(= closure1 closure2)will work only if they have the same fields (name) and if the values match(macro name value)/(macro name (args args args) body)/($if cond then else)(import package.sub.file)beginblock within a cond macro and used in the scope surrounding the cond macroarkscript --versionandarkscript --helpnow output ArkScript version with the commit hashvoid Value::toString(std::ostream&, VM&)now becomesstd::string Value::toString(VM&)Node::operator<<to replace it withNode::debugPrintlet,mutorset, resulting in a compiler crashargcountand crash the processor(fun)as the argument block, resulting in a crashlet/mut/setnodes(macro test (@ [1 2 3] -5))(concat! lst lst)(print nil?)(+)whilenodesfunnodeslet,mutorsetnodes inside macros with an invalid node typeinternal::listInstructionswith the different instructions, to be used by the compiler and name resolution passsymcatandargcountto$symcatand$argcountfor uniformityArk::VMclass is nowfinalSTOREinstruction has been renamedSET_VALSTOREinstruction is emitted in place of theLETandMUTinstructions, without any mutability checking nowio:writeFileno longer takes a mode and has been split intoio:writeFileandio:appendToFileinst byte1 byte2 byte3CALL_BUILTIN <builtin> <arg count>super instructionstr:xyzbuiltins tostring:xyzfor uniformity with the standard librarystring:findtakes an optional third argument, startIndex (where to start the lookup from, default 0list:setAtcan work with negative indexes, and is now bound checkedarkscriptexecutable (not enabled when embedding arkscript, so that one can grab variables from the VM)fmtlibto 11.1.3-13-bcroption can be given a source file, it will then be compiled before its bytecode is shownLOAD_SYMBOL_BY_INDEX, to avoid the sometimes expensive lookup by idArk::CodeErrornow takes aCodeErrorContextto store the source (filename, line, column, expression) of an errorstring:formattoformatio:removeFilesis nowio:removeFileand works on a single file/pathbuiltin__, to have them proxied in the standard library (to be able to import and scope them properly)CALL_BUILTIN_WITHOUT_RETURN_ADDRESSto optimize the proxied builtins, skipping the return address deletionawait&foo, you expect to be able to use.foonot.module:foo)Removed
NodeType::ClosureUtils::digPlacesandUtils::decPlacesgot removed as they were no longer neededlist:removeAt,arkexecutable now replaced byarkscript)VM::getUserPointerandVM::setUserPointerARK_PROFILER_COUNTdefine\0escape in stringstermcolordependency to rely onfmtfor coloring outputsandandorinstructions in favor of a better implementation to support short-circuitingLETandMUTinstructions in favor of a single newSTOREinstructionSAVE_ENVinstructionValue VM::resolve(const Value* val, Args&&... args), which has been deprecated in ArkScript v3.4.0This discussion was created from the release ArkScript v4.0.0.
Beta Was this translation helpful? Give feedback.
All reactions