Articles on Trending Technologies

Technical articles with clear explanations and examples

How to Call a Lua function from C?

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 3K+ Views

Calling a Lua function from C is something that requires a series of steps and a mastery in the Lua library functions. Lua provides several library functions that we can use whenever we want to call Lua functions from C or the opposite.Some of the most commonly used Lua library functions for calling a Lua function from C are −luaL_dofile(L, "myFile.lua");lua_getglobal(L, "add");lua_pushnumber(L, a);and much more.We will make use of these functions when we will call a Lua function from C.The first step is to shut down the Lua interpreter and for that we need to write a code in C.ExampleConsider ...

Read More

Command Line arguments in Lua

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 6K+ Views

Handling command line arguments in Lua is one of the key features of any programming language. In Lua, the command line arguments are stored in a table named args and we can use the indices to extract any particular command line argument we require.Syntaxlua [options] [script [args]]The options are −-e stat− executes string stat;-l mod− "requires" mod;-i− enters interactive mode after running script;-v− prints version information;--− stops handling options;-− executes stdin as a file and stops handlingoptions.ExampleLet’s consider an example where we will open a Lua shell in interactive mode and we will pass the script as dev/null and then we ...

Read More

Code indentation in Lua Programming

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 4K+ Views

Lua codes are not like Python when it comes to indentation. So, most of the code you will write will work even if it falls on another line, and you don’t necessarily need to have the nested code to be intended by a certain tab size.The code indentation in lua is more about making the code look much better and more readable. If your entire code is on one line or worse, if it is like multiple lines then I am afraid that your code isn’t very readable.While we can use the code editor’s indentation packages to do the indentation ...

Read More

io.popen() function in Lua Programming

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 18K+ Views

Sometimes we want to execute the system's command and then make use of whatever was returned by them, and in order to do that we simply can either make use of the os.execute() function or io.popen() function.The difference between the os.execute() function and the io.popen() function is that the output value of the os.execute() function is much harder to deal with, and that is the reason why it is recommended to use the io.popen() function, whose output value is much easier to handle and make use of.io.popen() starts the program in a separate process and returns a file handle that ...

Read More

Install Lua in Linux and implement PHP Lua Extension

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 584 Views

There are cases where we would like to implement PHP Lua extension in PHP.ini so that we can make use of Lua as an embedding language for our PHP code.It can be done with some series of steps that need to be run in a specific manner and the most important of them is running the --with-lua-version command.The steps for installing Lua in Linux are −pecl download lua cd lua-2.0.7In the steps above we made use of the pecl which stands for PHP extension community library to download lua and then we are relocating to the lua directory. Now, it’s ...

Read More

How to work with MySQL in Lua Programming?

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 2K+ Views

Lua provides different libraries that once can be used to work with MySQL. The most popular framework that enables us to work with MySQL in Lua is LuaSQL.LuaSQL is a simple interface from Lua to a DBMS. It enables a Lua program to −Connect to ODBC, ADO, Oracle, MySQL, SQLite, Firebird and PostgreSQL databases;Execute arbitrary SQL statements;Retrieve results in a row-by-row cursor fashion.You can download MySQL with the help of this command −luarocks install luasql-mysqlMySQL DB SetupIn order to use the following examples to work as expected, we need the initial db setup. The assumptions are listed below.You have installed ...

Read More

How to Use lua-mongo library in Lua Programming?

Mukul Latiyan
Mukul Latiyan
Updated on 20-Jul-2021 1K+ Views

Lua provides different libraries that can be used to work with MongoDB. The most popular framework that enables us to work with MongoDB in Lua is lua-mongo.Lua-mongo is a binding to MongoDB C Driver for Lua −It provides a Unified API for MongoDB commands, CRUD operations and GridFS in MongoDB C Driver.Transparent conversion from Lua/JSON to BSON for convenience.Automatic conversion of Lua numbers to/from BSON Int32, Int64 and Double types depending on their capacity without precision loss (when Lua allows it). Manual conversion is also available.You can download MongoDB with the help of this command −luarocks install lua-mongoMongoDB SetupIn order ...

Read More

What is Shelving?

Ginni
Ginni
Updated on 20-Jul-2021 2K+ Views

Shelving is an advanced issue mode, which is employed to eliminate issue blockages due to dependencies. Shelving makes use of dedicated instruction buffers, called shelving buffers, in front of each EU. Shelving decouples dependency checking from the instruction issue, and defers to it the dispatch phase.It can more precisely with shelving decoded instructions are used to shelving buffers despite data or control dependencies or busy EUs. This removes the issue bottleneck of the blocking issue.Specific resource constraints can restrict the processor to issue fewer instructions in a cycle than its issue rate. There are two resource constraints such as the ...

Read More

What is the design space of the Issue Rate?

Ginni
Ginni
Updated on 20-Jul-2021 877 Views

A superscalar processor is created to produce an execution rate of more than one instruction per clock cycle for a single sequential program. Superscalar processor design generally defines a set of techniques that enable the central processing unit (CPU) of a computer to obtain a throughput of more than one instruction per cycle while implementing a single sequential program.The concept of the superscalar issue was first developed as early as 1970 (Tjaden and Flynn, 1970). It was later reformulated more precisely in the 1980s (Torng, 1982, Acosta et al, 1986).The function of superscalar processing is the superscalar instruction issue. A ...

Read More

What are the Instruction issue policies of the superscalar processor?

Ginni
Ginni
Updated on 20-Jul-2021 2K+ Views

The following methods used in instruction issue policies such as the scalar processors, superscalar processors, and the broad picture covering both. While considering the most frequently used issue policies, it can reduce the design space of instruction issues by ignoring less important aspects.First, for both scalar and superscalar processors, it can avoid issue order, because most processors employ an in-order issue. Moreover, it can discard issue alignment in the case of scalar and superscalar processors that make use of shelving.While considering instruction issue policies for scalar processors, it should be treated the three basic issue aspects such as whether to ...

Read More
Showing 48851–48860 of 61,297 articles
Advertisements