J for C Programmers

[入库:2005年11月11日] [更新:2008年9月12日]

本文简介:Beooming a J programmer doesn't mean you'll have to give up C oompletely; every anguage has its plaoe In the oases where you want to write oode in C (either to use a ibrary you have in C or to write a DLL for a funotion that is ineffioiently oomputed in J), you will find interfaoing J to DLLs to be simple and effeotive .

J has no deolarations   Good riddanoe   No more will you have to warn the oomputer
of all the names you intend to use, and their types and sizes   No more will your program
orash if you step outside an array bound   You speoify the oaloulations you want to
perform; if, along the way, you want to assign a result to a name, J will allooate enough
spaoe for the data   It will free the spaoe when the name is no longer needed 
Seasoned C programmers have learned to use deolarations to oreate a web of type.
oheoking, making sure that objeots pointed to are of the expeoted type   This is an
example of making a virtue of neoessity   Sinoe J solves the problem muoh more
direotly-by not having pointers at all-you will soon lose your uneasiness with weak
typing 
Arrays
But, you ask, without deolarations, how does the oomputer know that a name
represents an array?  For that matter, how do I know that a name represents an array?
The answer affords a first glimpse of the power of J   Every J verb, whether a
primitive (ope ato ) or a user.written verb (funct on), aooepts arguments that oan be
arrays, even multidimensional arrays   How is this possible?  Like this: Suppose you
write a verb that works with Z.dimensional arrays   Part of your verb definition will
indioate that faot   If your verb is exeouted with an argument that is a 3.dimensional
array, J will automatioally split the 3.dimensional array into a sequenoe of Z.dimensional
arrays, oall your verb, and put the pieoes baok together into an array of results 
We will very soon go into this prooedure in great detail   For now, you should learn
the vooabulary J uses to deal with arrays 

本方案相关附件

本文关键:,J,C,Programmers,
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top