An environmental customization method, computing device, and storage medium
Patent Information
- Application Number
- CN202310233788.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-14
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2042-10-14
AI Technical Summary
但对语言进行直接修改,本质上是发明新的语言,会引起各种工程风险,特别是不同语言实现的可移植性问题,即不同语言编写的程序可能无法兼容,因此具体实用过程中会受到明显限制
[0021] Furthermore, the downstream second development environment, while retaining some interfaces of the upstream first development environment, can implement a second set of application interfaces by hiding and modifying some interfaces.
Smart Images

Figure CN116257287B_ABST
Abstract
Description
[0001] This application is a divisional application of an invention patent application filed on October 14, 2022, with application number 2022112576577 and invention title: An Environment Customization Method, Computing Device and Storage Medium. Technical Field
[0002] This invention relates to the field of computer development, and in particular to an environment customization method, computing device, and storage medium. Background Technology
[0003] Computer languages are divided into high-level languages and low-level languages. High-level languages are mainly in contrast to assembly languages. They are programming languages that are closer to natural language and mathematical formulas, and are basically independent of the machine's hardware system, allowing people to write programs in a more understandable way.
[0004] High-level languages can provide one or more features to implement functionality. These features are provided to users in the form of Application Programming Interfaces (APIs). Users can use libraries that include these interfaces to write programs in high-level languages. Therefore, language design often needs to provide different sets of features to meet the needs of different users, while keeping the core design unchanged, in order to balance versatility and flexibility.
[0005] Existing technologies often require modification and customization of the language itself to achieve new features. However, directly modifying a language is essentially inventing a new language, which can lead to various engineering risks, especially the portability issues between different language implementations. This means that programs written in different languages may not be compatible, thus significantly limiting their practical application.
[0006] Therefore, a new approach to environment customization is needed. Summary of the Invention
[0007] Therefore, the present invention provides an environment customization method in an attempt to solve or at least alleviate the problems mentioned above.
[0008] According to one aspect of the present invention, an environment customization method is provided, suitable for execution in a computing device, the method comprising: setting a first development language, the first development language including an interface customization method; constructing a first development environment according to the first development language, the first development environment including a first interface set, the first interface set including one or more interfaces, each interface setting characteristics of the first development environment; determining a second interface set according to the first interface set; and invoking the interface customization method to construct a second development environment according to the first development environment, the second development environment including the second interface set.
[0009] Optionally, in the method according to the present invention, constructing a first development environment according to a first development language includes: determining a first interface set according to the interfaces required by the first development environment and the second development environment; and constructing the first development environment according to the first interface set and the first development language.
[0010] Optionally, in the method according to the present invention, determining the second interface set based on the first interface set includes: determining the hidden interfaces that need to be hidden in the first interface set; removing the hidden interfaces from the first interface set to obtain the second interface set.
[0011] Optionally, in the method according to the present invention, determining the second interface set based on the first interface set includes: determining the modified interfaces in the first interface set that need to be modified; and determining the second interface set based on the modified interfaces and the first interface set.
[0012] Optionally, in the method according to the present invention, the interface customization method includes a removal method, and calling the interface customization method to construct a second development environment according to the first development environment includes: calling the removal method to remove the hidden interface from the first development environment to obtain the second development environment.
[0013] Optionally, in the method according to the present invention, the interface customization method includes a modification method, and calling the interface customization method to construct a second development environment according to a first development environment includes: calling the modification method to modify the modified interface in the first development environment to obtain the second development environment.
[0014] Optionally, in the method according to the present invention, the first development language further includes a name resolution method, the method further including: in response to a request to call a target interface in the second interface set, if it is determined according to the name resolution method that the target interface is provided by the first development environment, then calling the target interface from the first interface set.
[0015] Optionally, the method according to the present invention further includes: if the first development environment has one or more parent environments, and the target interface is provided by at least one of the parent environments, then determining the target parent environment that provides the target interface according to the name resolution method; and calling the target interface from the interface set corresponding to the target parent environment.
[0016] Optionally, in the method according to the present invention, the first development language further includes a first invocation method, the method further including: in response to a request to invoke a target interface in the second set of interfaces, obtaining the name and parent environment of the target interface according to the first invocation method; invoking a name resolution method according to the name and parent environment of the target interface, so that the name resolution method determines the target interface according to the name and parent environment of the target interface.
[0017] Optionally, in the method according to the present invention, the first development language further includes a second calling method, and the method further includes: when the target interface to be called is a modified interface, determining the name of the modified interface according to the second calling method so that the first calling method can obtain it.
[0018] According to another aspect of the present invention, a computing device is provided, comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for performing an environment-customized method according to the present invention.
[0019] According to another aspect of the invention, a computer-readable storage medium is provided for storing one or more programs, the one or more programs including instructions that, when executed by a computing device, cause the computing device to perform an environment-customized method according to the invention.
[0020] This invention discloses an environment customization method suitable for execution in a computing device. The method includes: setting a first development language, which includes an interface customization method; constructing a first development environment based on the first development language, the first development environment including a first interface set; determining a second interface set based on the first interface set; and calling the interface customization method to construct a second development environment based on the first development environment, the second development environment including the second interface set. This invention, by customizing the interfaces included in the development environment, allows different development environments to include different interface sets, enabling different development environments to use different feature sets.
[0021] Furthermore, the downstream second development environment, while retaining some interfaces of the upstream first development environment, can implement a second set of application interfaces by hiding and modifying some interfaces. Attached Figure Description
[0022] To achieve the foregoing and related objectives, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings. These aspects indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The foregoing and other objectives, features, and advantages of the present invention will become more apparent from the following detailed description taken in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.
[0023] Figure 1 A flowchart illustrating an environment customization method 100 according to an exemplary embodiment of the present invention is shown;
[0024] Figure 2 A structural block diagram of a computing device 200 according to an exemplary embodiment of the present invention is shown. Detailed Implementation
[0025] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art. The same reference numerals generally refer to the same parts or elements.
[0026] Figure 1 A schematic flowchart of an environment customization method 100 according to an exemplary embodiment of the present invention is shown.
[0027] One environment customization method of the present invention is suitable for execution in a computing device. Figure 2 A structural block diagram of a computing device according to an exemplary embodiment of the present invention is shown.
[0028] In a basic configuration, computing device 200 includes at least one processing unit 220 and system memory 210. According to one aspect, depending on the configuration and type of the computing device, system memory 210 includes, but is not limited to, volatile memory (e.g., random access memory), non-volatile memory (e.g., read-only memory), flash memory, or any combination of such memory. According to one aspect, system memory 210 includes an operating system 211.
[0029] According to one aspect, operating system 211, for example, is suitable for controlling the operation of computing device 200. Furthermore, the example is practiced in conjunction with graphics libraries, other operating systems, or any other applications, and is not limited to any particular application or system. Figure 2 The basic configuration is illustrated by the components within the dashed line 215. According to one aspect, the computing device 200 has additional features or functions. For example, according to one aspect, the computing device 200 includes additional data storage devices (removable and / or non-removable), such as disks, optical discs, or magnetic tapes.
[0030] As stated above, according to one aspect, program module 212 is stored in system memory 210. According to one aspect, program module 212 may include one or more applications. The invention does not limit the type of application; for example, applications also include: email and contact applications, word processing applications, spreadsheet applications, database applications, slideshow applications, drawing or computer-aided applications, web browser applications, etc.
[0031] According to one aspect, examples can be practiced on circuits including discrete electronic components, packaged or integrated electronic chips containing logic gates, circuits utilizing microprocessors, or on a single chip containing electronic components or a microprocessor. For example, it can be practiced via wherein... Figure 2 Each or many of the components shown can be implemented as an example of a system-on-a-chip (SoC) integrated on a single integrated circuit. According to one aspect, such a SoC device may include one or more processing units, graphics units, communication units, system virtualization units, and various application functions, all integrated (or “burned in”) onto a chip substrate as a single integrated circuit. When operated via the SoC, the functions described herein can be operated via dedicated logic integrated on a single integrated circuit (chip) with other components of the computing device 200. Embodiments of the invention can also be practiced using other techniques capable of performing logical operations (e.g., AND, OR, and NOT), including but not limited to mechanical, optical, fluid, and quantum technologies. Additionally, embodiments of the invention can be practiced within a general-purpose computer or in any other circuit or system.
[0032] According to one aspect, computing device 200 may also have one or more input devices 231, such as a keyboard, mouse, pen, voice input device, touch input device, etc. It may also include output devices 232, such as a monitor, speaker, printer, etc. The foregoing devices are examples and other devices may also be used. Computing device 200 may include one or more communication connections 233 that allow communication with other computing devices 240. Examples of suitable communication connections 233 include, but are not limited to: RF transmitter, receiver and / or transceiver circuitry; Universal Serial Bus (USB), parallel and / or serial ports. Computing device 200 can communicate with other computing devices 240 via communication connections 233.
[0033] This invention also provides a non-transitory readable storage medium storing instructions for causing a computing device to execute a method according to an embodiment of the invention. The readable medium in this embodiment includes both permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of readable storage media include, but are not limited to: phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transitory readable storage medium.
[0034] According to one aspect, a communication medium is implemented by computer-readable instructions, data structures, program modules, or other data in a modulated data signal (e.g., a carrier wave or other transmission mechanism), and includes any information transmission medium. According to one aspect, the term "modulated data signal" describes a signal having one or more sets of characteristics or altered in a manner that encodes information in the signal. By way of example and not limitation, a communication medium includes wired media such as wired networks or direct wired connections, and wireless media such as acoustic, radio frequency (RF), infrared, and other wireless media.
[0035] It should be noted that although the above-described computing device only shows the processing unit 220, system memory 210, input device 231, output device 232, and communication connection 233, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.
[0036] Please see Figure 1 First, execute step 110 to set the first development language, which includes interface customization methods.
[0037] According to one embodiment of the present invention, the development language can be further developed. The development language includes a high-level language. Secondary development refers to upstream developers setting up the development language to obtain a first development language, followed by downstream developers resetting it based on the first development language to obtain a second development language; further downstream developers can also use the second development language as a blueprint to perform secondary development to meet corresponding requirements. Each new development language is compatible with the original development language, but the set of features it supports differs.
[0038] The features supported by a programming language refer to the functionalities or properties of the programming language as defined by specific language rules. A feature set is a collection of one or more features supported by a programming language.
[0039] In contrast, relying directly on the language features provided by an existing development language and using that language as a development tool for program design and writing without changing the original features of the existing language is merely using the language for program development, not language development.
[0040] In existing technologies, in order to support new features, syntax that the upstream development language cannot recognize is used. After secondary development, the language compatibility is poor, and the developed application cannot run incompatible with the original application.
[0041] According to one embodiment of the present invention, the present invention does not limit the specific language type of the development language, and the development language can be specifically implemented as a high-level language capable of providing abstractions through variable names. The development language includes a first development language, a second development language, and languages developed based on the first or second development language, etc.
[0042] The first development language can be used to build a development environment, such as a first development environment, and to implement the interfaces included in the development environment, such as the first set of interfaces included in the first development environment. The first set of interfaces includes one or more interfaces.
[0043] The first development language includes interface customization methods. This invention does not limit the specific types and number of methods included in the first development language. According to one embodiment of the invention, the methods included in the first development language can be specifically implemented as primitives.
[0044] Interface customization methods are used to customize interfaces. These methods include removal methods, modification methods, etc. This invention does not limit the specific types or number of methods included in the interface customization methods. According to one embodiment of the invention, the methods included in the interface customization methods can be specifically implemented as primitives.
[0045] An API is a concrete implementation of an interface for application or program development. It is a way for developers to provide features using a development language, and also a way for the development language to provide these features to other users.
[0046] According to one embodiment of the present invention, the interface provided by the development environment can be specifically implemented as a variable. Variables include functions, as well as language macro names and reserved words that provide features, such as the `while` control flow keyword and the `class` type definition keyword.
[0047] A programming language has a language specification, which defines which variable bindings an environment should have, and thus what features it should include. This specification defines the set of features provided by the programming language. Setting the feature set of the programming language is the process of setting the language specification. This invention can provide the set language specification to downstream developers so that they can reuse the programming language configured according to the specification.
[0048] According to one embodiment of the present invention, in addition to the interface customization method, the first development language also includes basic language features, such as syntax and semantic rules for expressions, variables, functions, function calls, and sequential evaluation, to support the use of these rules to call one or more interfaces provided in the environment in the first development language.
[0049] According to one embodiment of the present invention, the first development language is further configured with other supported syntactic extensions and corresponding semantic rules in addition to basic language features, and provides a set of basic language features that can be used by secondary developers in conjunction with other methods.
[0050] According to one embodiment of the present invention, the development language of the present invention can be specifically implemented as an interpreter, based on which downstream developers can use the development language. The interpreter implements the interface provided in the initial environment. The interpreter can be implemented using a native language (such as C++), and data that needs to be directly processed by the interpreter, such as variable names and environment, has a separate data type.
[0051] According to one embodiment of the present invention, the variable names used as data have a symbol type and internally store C++ string values. Entities have an object type and are internally implemented as C++ type-erased objects (std::any type).
[0052] According to one embodiment of the present invention, the expression can be internally represented as a C++ class TermNode, which recursively contains std::list <termnode>It has a Container data member and an Object type Value data member. Lists are represented by empty Values with TermNode values. Other values in the language are represented by empty Containers and non-empty Values with TermNode values. Expressions are implemented as Abstract Syntax Trees (ASTs) and are internally nested lists. Object references outside the environment are implemented as TermReference classes, which internally store TermNode data.
[0053] According to one embodiment of the present invention, the environment implementation may be specifically an Environment class, which stores variable bindings, i.e., a collection of symbols and entities (which may be implemented as a C++ std::map).<Symbol,Object> It also has a reference to its parent environment. For ease of control over resource management and local interoperability, std::shared_ptr is used. <environment>and std::weak_ptr <environment>Distinguishing between strong and weak references is crucial to avoid resource leaks caused by circular references. Weak references are used by default, and they are only temporarily converted to strong references when the object must be accessed. This also helps prevent the garbage collector from prematurely reclaiming resources.
[0054] According to one embodiment of the present invention, the interface (API) corresponding to the primitives in the present invention can be implemented through the interpreter's own functionality. The API is provided in the initial environment, either by evaluating the code snippet of the API corresponding to the `define` primitive, or by directly modifying the native API of variable bindings within the environment internally by the interpreter. Modification of variable bindings is not restricted internally by the interpreter; `define` and `undef` can directly implement `insert` and `erase` for `map`. Downstream developers who further customize the environment, if they want to maintain portability without relying on the specific implementation within the interpreter, use the former method to modify the variable bindings in the new environment; without a reference to the environment, the variable bindings cannot be accessed outside of name resolution.
[0055] According to one embodiment of the present invention, based on the internal representation of the environment's data structure, the underlying implementation of the create-environment primitive can be achieved by calling std::make_shared. <enviornment>Create a shared_ptr that references the new Environment object. <environment>The value is implemented by obtaining the operands and verifying that these operands represent environment references before setting the parent environment reference within the newly created Environment object.
[0056] According to one embodiment of the present invention, variables that can be called as functions all have a function type. This primitive is also provided as a variable of function type, as a Function class. Its internal implementation can use objects of C++'s std::function function instances. It accepts parameters of type TermNode& and Context&. A function call in the language is a call to Function, which causes a call to std::function, internally rewriting the TermNode specified by the parameter. After the call, the TermNode object referenced by TermNode& is the output call result. This calling convention of directly rewriting the input corresponds to the rewriting logic of the AST interpreter. The API corresponding to the primitive can be directly implemented as a Function. The Function itself is only responsible for the execution of the function body, not for the evaluation of the parameters. The other data members of the Function determine whether the parameters need to be evaluated in the evaluation algorithm before the function body.
[0057] According to one embodiment of the present invention, the entire interpreter initialization state is stored in a context represented by the Context class. An object of the Context class is initialized when the interpreter is created. The Context stores a shared_ptr named Current for the current environment. <environment>For data members of a type, the interpreter creates an empty environment during initialization. Following the described process, it initializes the functions corresponding to primitives like `eval` to `Function` values representing C++ functions implemented internally by the interpreter. The function names are used as variables, and the variables represented by the `Function` values are bound and stored in this environment. This environment is the implementation of the base environment. After initialization, a new environment is created to replace the current `Current` value, and the original `Current` value is used as the parent environment reference of the newly created environment. This achieves the hiding of the base environment. As a command-line program, the interpreter implements a REPL (read-eval-print loop) after initialization. The input program is parsed and converted into an AST represented by a TermNode, and then `eval` is called to execute the program represented by the AST. Replacing the implementation of `read` from standard input with file input and then calling `eval` implements the functionality of the `load` primitive.
[0058] According to one embodiment of the present invention, the interpreter's function calls implicitly include `Context&` to ensure that the function call always accesses the current environment `Context::Current`. Based on this, an implementation of the `get-current-environment` primitive can be directly provided: retrieve `Context::Current` and convert it to `weak_ptr`. <environment>The value is set to an empty TermNode's Value data member.
[0059] According to one embodiment of the present invention, the internal logic of the `eval` primitive is as follows: If the expression (TermNode value) is a variable name (containing only non-empty `Value` values and whose target is a `Symbol` type value), then name resolution is performed, replacing the expression containing the variable name with a reference to the referent entity (the `TermNode` reference obtained by accessing the iterator of the name resolution result is used to initialize the `TermReference` value); otherwise, if the expression is a combination of a function and operands (a list of functions and parameters), depending on the function's purpose, if the operands need to be evaluated as subexpressions, the expression is first recursively evaluated (recursively calling this algorithm); for the combination of the function and operands that have already been evaluated, the function is called with the operands as parameters; otherwise, unless otherwise specified by the language specification or custom developer, if the expression is self-evaluated, it is considered already evaluated and no further operation is needed. For example, if the target of `Value` is the `TermNode` of `TermReference`, the expression is self-evaluated.
[0060] According to one embodiment of the present invention, providing the API corresponding to `eval` also requires treating `eval` as a function, evaluating the parameters of `eval` (the two operands of the `eval` primitive), and then entering the corresponding function body to execute the above logic. Custom developers can provide APIs similar to those with `eval` functionality in the initial environment, allowing downstream developers to customize more complex evaluation algorithms (this implementation is called a meta-circular evaluator), without changing the upstream evaluation algorithm in the initial environment.
[0061] According to one embodiment of the present invention, the development language of the present invention also includes corresponding data structures such as data structures corresponding to functions and data structures corresponding to the input of name resolution methods.
[0062] Subsequently, step 120 is executed, in which a first development environment is constructed based on the first development language. The first development environment includes a first interface set, which includes one or more interfaces, each of which sets the characteristics of the first development environment.
[0063] According to one embodiment of the present invention, the environment of the present invention, such as a first development environment, a second development environment, etc., includes an evaluation environment, which may specifically be a container for variable binding, that is, a data structure that stores the mapping from variable names to variable values.
[0064] According to one embodiment of the present invention, when constructing a first development environment based on a first development language, a first interface set is determined based on the interfaces required by the first development environment and the second development environment; then, the first development environment is constructed based on the first interface set and the first development language, so that the interfaces used by all development environments downstream of the first development environment are provided by the first interface set.
[0065] According to one embodiment of the present invention, the process of constructing a development environment based on a development language is that of initializing the environment according to the development language. When constructing the development environment, an empty basic environment is first created. Then, based on the first set of interfaces corresponding to the feature set that the first development environment should provide, variables are bound to the interfaces in the interface set. During variable binding, the variables include interface functions corresponding to define, undef, eval, and create-environment, as well as interface functions to be provided to downstream developers, but excluding interface functions that could affect the security of the first development environment.
[0066] According to one embodiment of the present invention, the first interface set of the first development environment further provides interfaces for hiding and modifying interfaces in the first interface set, such as calling a removal method interface to hide the interface; calling a modification method interface to modify the interface; calling a switching environment method to switch the current development environment; and calling a first calling method and a second calling method, etc.
[0067] According to one embodiment of the present invention, the first development environment created is also preserved to ensure that it is available throughout the entire lifecycle of the subsequent program, and that related resources are not prematurely destroyed by the resource management mechanism (such as the garbage collector) in the development language.
[0068] According to one embodiment of the present invention, downstream developers can implement their programs directly using the interfaces provided by the language, just like regular users, without considering a custom development language. If further customization of the development language is required, the upstream language specification is used as a basis to design a new language specification, including all the modifications expected to be provided to downstream developers. A new development language is implemented according to the new language specification, internally possessing all the functionalities implemented by the upstream development language, while providing the features provided by the new language specification only to users using the new development language.
[0069] Subsequently, step 130 is executed to determine the second interface set based on the first interface set.
[0070] According to one embodiment of the present invention, when determining the second interface set based on the first interface set, the hidden interfaces that need to be hidden in the first interface set are determined; the hidden interfaces are removed from the first interface set to obtain the second interface set.
[0071] According to one embodiment of the present invention, when determining hidden interfaces, the security of the development environment can be considered, and defensive designs can be adopted to address security issues. For example, if one or more interfaces in the first set of interfaces are identified that would compromise the security of the first development environment, these interfaces are designated as hidden interfaces. This prevents downstream developers from using these interfaces in the second development environment, thus preventing them from modifying the corresponding configurations through these interfaces to compromise security, thereby ensuring the security of the first development environment.
[0072] According to one embodiment of the present invention, when determining a second interface set based on a first interface set, the interfaces in the first interface set that need to be modified are determined; the second interface set is determined based on the modified interfaces and the first interface set. When determining the modified interfaces, interfaces that need to change the functions or characteristics provided by the original interfaces can be identified as the modified interfaces.
[0073] Finally, step 140 is executed, the interface customization method is called, and the second development environment is constructed based on the first development environment. The second development environment includes the second set of interfaces.
[0074] According to one embodiment of the present invention, a first development environment includes a first set of interfaces, and a second development environment includes a second set of interfaces. Compared to the second development environment, the first development environment includes a raw set of interfaces and provides a raw set of features. The second development environment includes a customized set of interfaces and provides a customized set of features. When using the second set of interfaces, the second development environment can use some features from the raw set of features, while the first development environment can use all features from the raw set of features.
[0075] Based on the needs of the second development environment, the second interface set, compared to the first interface set, hides or modifies interfaces in the original interface set, thereby hiding or modifying features in the original feature set. These hidden features may specifically be features that, if modified, would compromise the development environment, such as security; the hidden or modified interfaces may specifically be those that affect security; these interfaces cannot be accessed by downstream developers or other users to ensure the security of the development environment.
[0076] According to one embodiment of the present invention, the upstream development environment can create new downstream development environments by customizing its interfaces, but does not provide interfaces that can modify the upstream development environment. The most upstream development environment is the initial environment, which cannot be modified by all downstream developers and is hidden from downstream users; the environment provided to downstream developers is a new environment defined and created based on this initial environment. When upstream developers provide a new development environment to downstream users, they do so by creating a new development environment and switching the existing environment to the new one, without providing the original environment to the user, thus preventing downstream users from modifying the original environment.
[0077] According to an embodiment of the present invention, the interface customization method includes a removal method. Calling the interface customization method and constructing a second development environment based on a first development environment includes: calling the removal method to remove the hidden interface from the first development environment to obtain the second development environment.
[0078] The remove method is used to remove (or hide) one or more interfaces in the development environment.
[0079] According to one embodiment of the present invention, the removal method can be specifically implemented as the undef method, which has the specific form of: undef<variable name>.
[0080] According to one embodiment of the present invention, the interface customization method includes a modification method. When constructing a second development environment based on a first development environment, the modification method is called to modify the interface in the first development environment to obtain the second development environment.
[0081] The modification method is used to modify one or more interfaces in the development environment.
[0082] According to one embodiment of the present invention, the modification method can be used to modify the original interface, setting it to have different characteristics than the original, or to define and add new interfaces in the interface set to implement new characteristics.
[0083] According to one embodiment of the present invention, the modification method can be specifically implemented as the define method, which has the specific form of: define<variable name><expression for variable definition>.
[0084] According to one embodiment of the present invention, the first development language further includes an environment creation method for providing one or more existing development environments to create a new development environment, such that the newly created development environment references the existing development environment, and the interfaces in the existing development environment can be called by the newly created development environment, but the existing development environment is hidden from users using the new development environment.
[0085] According to one embodiment of the present invention, the environment creation method can be specifically implemented as a create-environment method, which is in the form of create-environment<environment>.
[0086] According to one embodiment of the present invention, the first development language further includes a name resolution method, and the method of the present invention further includes: in response to a request to call a target interface in the second interface set, if it is determined according to the name resolution method that the target interface is provided by the first development environment, then calling the target interface from the first interface set.
[0087] According to one embodiment of the present invention, a first development environment is the parent environment of a second development environment, and the second development environment is a child environment of the first development environment. The first development language includes a name resolution method, and the second development environment constructed based on the first development environment also includes a name resolution method.
[0088] The name resolution method provides a name resolution mechanism that, starting with the current development environment, retrieves and matches parent environments including the input target interface based on one or more parent environments referenced by the development environment and the target interface. This allows the corresponding features to be implemented by calling the interface in the parent environment when the current development environment references the parent environment.
[0089] The name resolution method includes a first input and a second input. The first input includes the parent environment of the current development environment, and the second input includes the target interface to be retrieved. According to one embodiment of the present invention, the first input may include the parent environment of the current development environment.
[0090] According to one embodiment of the present invention, the name resolution method can be implemented as: eval<expression containing variable name><environment>.
[0091] If the first development environment has one or more parent environments, and the target interface is provided by at least one of the parent environments, then the target parent environment providing the target interface is determined according to the name resolution method; the target interface is called from the interface set corresponding to the target parent environment.
[0092] A development environment may have one or more parent environments. This invention does not limit the specific number of parent environments for a development environment. These parent environments can reference each other, forming a reference hierarchy.
[0093] According to one embodiment of the present invention, a second development environment is generated based on a first development environment. The second development environment references the first development environment. The first development environment is the parent environment of the second development environment, and the second development environment is the child environment of the first development environment.
[0094] According to one embodiment of the present invention, if the name resolution method does not find the target interface based on the parent environment of the current environment, it indicates that a higher-level call exists, and it is necessary to find a higher-level parent environment based on the parent environment of the parent environment. The environment referenced by the parent environment is also the parent environment indirectly referenced by the current development environment.
[0095] If the target interface to be called is not found in any parent environment according to the name resolution method, an error message will be displayed; otherwise, enter the parent environment including the target interface, and determine the target interface based on that parent environment and make the call.
[0096] The name resolution mechanism provided by the name resolution method allows interfaces with the same name to appear and be used in multiple development environments, while also ensuring the implementation of customized environments. Furthermore, the parent environment of the current development environment is invisible to developers using the current environment; users can only operate within the current development environment but can still call interfaces provided by the parent environment, thus improving the security and flexibility of the development environment.
[0097] According to one embodiment of the present invention, the name resolution algorithm can be specifically a depth-first search (DFS) algorithm. The present invention does not limit the specific implementation of the name resolution algorithm. During execution, the development environment determines the parent environment of the current environment using a map function. First, it checks whether the specified target interface exists in the parent environment using `std::map::find`. If found, the interface is retrieved from the parent environment and returned. If not found, the search continues level by level, examining each parent environment. If ultimately no interface is found, an exception is thrown, and an error handling function is executed.
[0098] According to one embodiment of the present invention, the first development language further includes a first invocation method. The method further includes: in response to a request to invoke a target interface in a second set of interfaces, obtaining the name and parent environment of the target interface according to the first invocation method; and invoking a name resolution method according to the name and parent environment of the target interface, so that the name resolution method determines the target interface based on the name and parent environment of the target interface. The first invocation method is capable of determining a first input and a second input to a name resolution algorithm, so as to invoke the name resolution algorithm according to the first input and the second input.
[0099] According to one embodiment of the present invention, the parent environment of the current development environment can be obtained through the get-current-environment method. The present invention does not limit the specific method of obtaining the parent environment.
[0100] According to one embodiment of the present invention, when the target interface to be called is a modified interface, the name of the modified interface is determined according to a second calling method so that the first interface method can obtain it. The second calling method is used to determine the new interface defined according to the define primitive so that the name of the new interface is provided to the first calling method as the second input of the name resolution algorithm.
[0101] According to one embodiment of the present invention, a user using a second development environment can develop within the second development environment to obtain a third development environment for downstream users. Specifically, the second development environment is used as the current environment through an environment switching method, and then the third development environment is constructed based on the second development environment. When constructing the third development environment based on the second development environment, interfaces in the second interface set are removed or modified by calling an interface customization method to construct a third interface set for the third development environment; and the third development environment is made dependent on the second development environment, enabling it to call interfaces in the second interface set through a name resolution method. Finally, the third development environment is provided to downstream users.
[0102] According to one embodiment of the present invention, when using a second development environment, an application or program following a new development language is loaded and run in the second development environment through the interface corresponding to the constructed load function; specifically: the expression of the application or program is used as the first operand, the expression of the second development environment is used as the second operation data, and the name resolution method is called to run the application or program.
[0103] In this invention, as long as the process of customizing the new environment is not known to downstream users, downstream users cannot access the parent environment of the new environment, but can only call the interfaces therein to implement the corresponding features.
[0104] According to one embodiment of the present invention, an example of a first development environment is as follows:
[0105] void Define(TermNode&,Context&);
[0106] void Undef(TermNode&,Context&);
[0107] void CreateEnvironment(TermNode&,Context&);
[0108] void Init(Context&c)
[0109] {
[0110] c.Current = make_shared <environment>();
[0111] auto¤t(c.Current);
[0112] auto&bd(current.Bindings);
[0113] bd.emplace("define",Function(Define,0)); / / 0=No need to evaluatearguments.
[0114] bd.emplace("undef",Function(Undef,0));
[0115] bd.emplace("create-enviornment",Function(CreateEnviornment,1)); / / 1=Need to evaluate arguments.
[0116] / / ...
[0117] c.Ground=make_shared <environment>(c.Current);
[0118] swap(c.Ground,c.Current); / / Switch to the new environment,save and hide the ground.
[0119] }
[0120] The following is a specific example of a second development environment built based on the first development environment:
[0121] (define new-env(create-environment(get-current-environment)))
[0122] (eval'(define'eval(lambda args(error"Calling'eval'is not allowed!")))new-env)
[0123] (eval'(load"program")new-env); "program" is some conventional name.
[0124] Compared to the second development environment, the second development environment no longer provides the original eval function interface. The eval function interface has been modified to have new functions and features.
[0125] According to one embodiment of the present invention, in order to repeatedly call external code in the development environment, the load method can be used for invocation. The load method can be specifically a primitive, which has the form: load<expression specifying program name>.
[0126] According to one embodiment of the present invention, after the custom environment is established, if the custom developer removes the API, the implementation of the undef API can adopt an appropriate resource management method to ensure that the entities referred to in the no longer visible API are properly stored, so as to ensure that the entities corresponding to these APIs that are not visible to downstream users and may be used within the custom implementation can still be accessed. This storage method can be an object pool or a garbage collector, etc., determined by the language implementation scheme that provides the initial environment. This storage implementation also ensures that the environment as data can be shared, avoiding the need for arbitrary copying of variable bindings.
[0127] The primitives exemplified in this invention are merely illustrative. This invention does not limit the names and syntax derived from them in specific development environments; these are determined as needed by the specific language specifications of the initial development environment. This invention also enables the customization of the functional characteristics of existing interfaces while maintaining their original names through interface customization methods.
[0128] This invention, by setting language rules, such as methods, within the development language, enables the language to meet the needs of developers at different stages. Both upstream and downstream developers can implement different functions using a customized development language based on different feature sets. Simultaneously, by using the feature sets provided by the customized language, certain functions or interfaces for downstream developers can be shielded, improving the security and stability of the development environment at each stage. Specifically, this can be achieved by restricting the interfaces available to downstream developers, thus customizing their development environment. Furthermore, both upstream and downstream development environments share some common characteristics, which downstream developers can utilize to improve development efficiency.
[0129] This solution reduces potential compatibility issues caused by adding new extended language features by setting up interfaces. As long as the development language provides a usable interface, downstream developers do not need to perform specific configurations of the language, thereby eliminating program portability issues between the development language used for secondary development and the original development language.
[0130] This invention addresses the needs of both primary and secondary development processes for programming languages, providing reusability for programming languages and corresponding development environments, reducing the need for repetitive development work, and effectively avoiding potential compatibility risks. Since the interface customization method of this solution is entirely provided by the inherent characteristics of the high-level language, a well-designed set of original features significantly improves flexibility and portability compared to existing technologies, while reducing customization difficulty, overall complexity, and development costs. Furthermore, this invention, with a consistent set of interfaces, enables the provision of further customized features to downstream developers at multiple levels, contributing to the promotion and formation of a new developer ecosystem.
[0131] This invention discloses an environment customization method suitable for execution in a computing device. The method includes: setting a first development language, which includes an interface customization method; constructing a first development environment based on the first development language, the first development environment including a first interface set; determining a second interface set based on the first interface set; and calling the interface customization method to construct a second development environment based on the first development environment, the second development environment including the second interface set. This invention customizes the interfaces included in the development environment, setting different development environments to include different interface sets, thus enabling different development environments to use different feature sets. Furthermore, the downstream second development environment, while retaining some interfaces of the upstream first development environment, can achieve the application of the second interface set by hiding and modifying some interfaces.
[0132] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0133] Similarly, it should be understood that, in order to streamline this disclosure and aid in understanding one or more of the various aspects of the invention, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof.
[0134] Those skilled in the art will understand that the modules, units, or groups of devices in the examples disclosed herein can be arranged in the device as described in this embodiment, or alternatively, can be located in one or more devices different from the device in this example. The modules in the foregoing examples can be combined into a single module or, in addition, can be divided into multiple sub-modules.
[0135] Those skilled in the art will understand that modules in the apparatus of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or groups in the embodiments can be combined into a single module, unit, or group, and further, they can be divided into multiple sub-modules, sub-units, or sub-groups. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed herein and all processes or units of any method or apparatus so disclosed. Unless expressly stated otherwise, each feature disclosed herein may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0136] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention and form different embodiments.
[0137] Furthermore, some of the embodiments described herein are methods or combinations of method elements that can be implemented by a processor of a computer system or by other means of performing the functions. Therefore, a processor having the necessary instructions for implementing the methods or method elements forms means for implementing the methods or method elements. Furthermore, the elements described herein in the apparatus embodiments are examples of means for implementing the functions performed by elements for the purposes of carrying out the invention.
[0138] The various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embedded in a tangible medium, such as a floppy disk, CD-ROM, hard disk, or any other machine-readable storage medium, wherein when the program is loaded into and executed by a machine such as a computer, the machine becomes an apparatus for practicing the present invention.
[0139] When the program code is executed on a programmable computer, the computing device generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store program code; the processor is configured to execute the environment customization method of the present invention according to instructions in the program code stored in the memory.
[0140] By way of example, and not limitation, computer-readable media include computer storage media and communication media. Computer storage media stores information such as computer-readable instructions, data structures, program modules, or other data. Communication media generally embodies computer-readable instructions, data structures, program modules, or other data in the form of modulated data signals such as carrier waves or other transmission mechanisms, and includes any information delivery medium. Any combination of the above is also included within the scope of computer-readable media.
[0141] As used herein, unless otherwise specified, the use of ordinal numbers “first,” “second,” “third,” etc., to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that such objects must have a given order in time, space, sequence, or any other manner.
[0142] Although the invention has been described with reference to a limited number of embodiments, those skilled in the art will understand from the foregoing description that other embodiments are conceivable within the scope of the invention described herein. Furthermore, it should be noted that the language used in this specification has been chosen primarily for readability and edibility purposes, and not for the purpose of explaining or limiting the subject matter of the invention. Therefore, many modifications and variations will be apparent to those skilled in the art. The disclosure of the invention regarding its scope is illustrative and not restrictive.< / environment> < / environment> < / environment> < / environment> < / environment> < / enviornment> < / environment> < / environment> < / termnode>
Claims
1. An environment customization method, suitable for execution in a computing device, the method comprising: Set a first development language, which includes interface customization methods; A first development environment is constructed based on a first development language. The first development environment includes a first set of interfaces, which includes one or more interfaces. Each interface sets the characteristics of the first development environment. Determine the second interface set based on the first interface set; The interface customization method is invoked to construct a second development environment based on the first development environment. The second development environment includes a second set of interfaces and is a downstream development environment of the first development environment. The first development language also includes a name resolution method, the method further including: In response to a request to invoke a target interface in the second interface set, if the target interface is determined to be provided by the first development environment according to the name resolution method, then the target interface is invoked from the first interface set.
2. The method as described in claim 1, wherein, Building the first development environment based on the first development language includes: The first interface set is determined based on the interfaces required by the first development environment and the second development environment; A first development environment is constructed based on the first set of interfaces and the first development language.
3. The method as described in claim 1, wherein, Determining the second interface set based on the first interface set includes: Identify the hidden interfaces that need to be hidden in the first set of interfaces; Remove the hidden interface from the first interface set to obtain the second interface set.
4. The method of claim 1, wherein, Determining the second interface set based on the first interface set includes: Identify the interfaces in the first set of interfaces that need to be modified; The second interface set is determined based on the modified interface and the first interface set.
5. The method of claim 3, wherein, The interface customization method includes a removal method, and the step of calling the interface customization method to construct a second development environment based on the first development environment includes: The hidden interface is removed from the first development environment by calling the removal method, thus obtaining the second development environment.
6. The method of claim 4, wherein, The interface customization method includes a modification method, and the step of calling the interface customization method to construct a second development environment based on the first development environment includes: The modification method is invoked to modify the modification interface in the first development environment to obtain the second development environment.
7. The method of claim 1, wherein, The method further includes: If the first development environment has one or more parent environments, and the target interface is provided by at least one of the parent environments, then the target parent environment providing the target interface is determined according to the name resolution method. The target interface is invoked from the set of interfaces corresponding to the target parent environment.
8. The method according to any one of claims 1-7, wherein, The first development language also includes a first invocation method, which further includes: In response to a request to invoke a target interface in the second set of interfaces, the name and parent environment of the target interface are obtained according to the first invocation method; The name resolution method is invoked based on the name of the target interface and the parent environment, so that the name resolution method can determine the target interface based on the name of the target interface and the parent environment.
9. The method of claim 8, wherein, The first development language also includes a second calling method, which further includes: When the target interface to be called is a modification interface, the name of the modification interface is determined according to the second calling method so that the first calling method can obtain it.
10. A computing device, comprising: One or more processors; Memory; as well as One or more programs, wherein the programs are stored in memory and configured to be executed by one or more processors, and the programs include instructions for performing the method according to any one of claims 1-9.
11. A computer-readable storage medium storing one or more programs, said one or more programs including instructions that, when executed by a computing device, cause the computing device to perform the method according to any one of claims 1-9.
Citation Information
Patent Citations
Method and device for expanding programming language features
CN106484489A
Application program interface management device and construction method thereof
CN113672222A